File: destroy.js

package info (click to toggle)
ckeditor 4.5.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 30,020 kB
  • sloc: sh: 167; python: 37; makefile: 24; php: 15; xml: 5
file content (62 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: toolbar,button,stylescombo */

bender.editor = true;

bender.test(
{
	'test destroy editor with rich combo panel opened': function() {
		var bot = this.editorBot, editor = this.editor;
		bot.combo( 'Styles', function( combo ) {
			var panelEl = combo._.panel.element;
			editor.destroy();
			assert.isFalse( CKEDITOR.document.getBody().contains( panelEl ) );

			// #4552: Do that one more time.
			bender.editorBot.create( {}, function( bot ) {
				this.wait( function() {
					bot.combo( 'Styles', function( combo ) {
						var panelEl = combo._.panel.element;

						bot.editor.destroy();
						assert.isFalse( CKEDITOR.document.getBody().contains( panelEl ) );
					} );
				}, 0 );
			} );

		} );
	},

	// #13385.
	'test getSnapshot returns empty string after editor destroyed': function() {
		bender.editorBot.create( {}, function( bot ) {
			this.wait( function() {
				var editor = bot.editor;
				editor.destroy();
				assert.areSame( '', editor.getSnapshot() );
			}, 0 );
		} );
	},

	'test destroy editor before it is fully initialized': function() {
		var name = 'test_editor',
			element,
			editor,
			warnStub = sinon.stub( CKEDITOR, 'warn' );

		element = CKEDITOR.document.getById( name );
		this.editor.destroy();

		editor = CKEDITOR.replace( element );
		editor.destroy();

		// initConfig is called asynchronously.
		wait( function() {
			warnStub.restore();
			assert.isTrue( warnStub.calledOnce, 'CKEDITOR.warn should be called once.' );
			assert.areEqual( 'editor-incorrect-destroy', warnStub.firstCall.args[ 0 ],
				'CKEDITOR.warn error code should be "editor-incorrect-destroy".' );
		}, 0 );

	}
} );