8
0
Просмотр исходного кода

Removed duplicated editor.data#ready event fired.

Maciej Bukowski 6 лет назад
Родитель
Сommit
b215ab71e6

+ 19 - 0
packages/ckeditor5-core/tests/_utils-tests/virtualtesteditor.js

@@ -41,6 +41,8 @@ describe( 'VirtualTestEditor', () => {
 			return VirtualTestEditor.create( { initialData: '<p>foo</p>', plugins: [ Paragraph ] } )
 				.then( editor => {
 					expect( editor.getData() ).to.equal( '<p>foo</p>' );
+
+					return editor.destroy();
 				} );
 		} );
 
@@ -48,6 +50,23 @@ describe( 'VirtualTestEditor', () => {
 			return VirtualTestEditor.create()
 				.then( editor => {
 					expect( editor.getData() ).to.equal( '' );
+
+					return editor.destroy();
+				} );
+		} );
+
+		it( 'fires the `data#ready` event once', () => {
+			const dataReadySpy = sinon.spy();
+
+			const Plugin = editor => {
+				editor.data.on( 'ready', dataReadySpy );
+			};
+
+			return VirtualTestEditor.create( { plugins: [ Plugin ] } )
+				.then( editor => {
+					sinon.assert.calledOnce( dataReadySpy );
+
+					return editor.destroy();
 				} );
 		} );
 	} );

+ 0 - 3
packages/ckeditor5-core/tests/_utils/virtualtesteditor.js

@@ -35,9 +35,6 @@ export default class VirtualTestEditor extends Editor {
 				editor.initPlugins()
 					.then( () => {
 						editor.data.init( config.initialData || '' );
-
-						// Fire `data#ready` event manually as `data#init()` method is not used.
-						editor.data.fire( 'ready' );
 						editor.fire( 'ready' );
 					} )
 					.then( () => editor )