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

Merge pull request #274 from ckeditor/t/273

Internal: Fixed failing test in `ImageUploadEditing`. Closes #273.
Maciej 7 лет назад
Родитель
Сommit
8b2c57cb46
1 измененных файлов с 10 добавлено и 18 удалено
  1. 10 18
      packages/ckeditor5-image/tests/imageupload/imageuploadediting.js

+ 10 - 18
packages/ckeditor5-image/tests/imageupload/imageuploadediting.js

@@ -535,28 +535,20 @@ describe( 'ImageUploadEditing', () => {
 
 		editor.execute( 'imageUpload', { file } );
 
-		model.document.once( 'change', () => {
-			// This is called after "manual" remove.
-			model.document.once( 'change', () => {
-				// This is called after attributes are removed.
-				let undone = false;
-
-				model.document.once( 'change', () => {
-					if ( !undone ) {
-						undone = true;
+		const stub = sinon.stub();
+		model.document.on( 'change', stub );
 
-						// This is called after abort remove.
-						expect( getModelData( model ) ).to.equal( '<paragraph>[]foo bar</paragraph>' );
+		// The first `change` event is fired after the "manual" remove.
+		// The second `change` event is fired after cleaning attributes.
+		stub.onSecondCall().callsFake( () => {
+			expect( getModelData( model ) ).to.equal( '<paragraph>[]foo bar</paragraph>' );
 
-						editor.execute( 'undo' );
+			editor.execute( 'undo' );
 
-						// Expect that the image has not been brought back.
-						expect( getModelData( model ) ).to.equal( '<paragraph>[]foo bar</paragraph>' );
+			// Expect that the image has not been brought back.
+			expect( getModelData( model ) ).to.equal( '<paragraph>[]foo bar</paragraph>' );
 
-						done();
-					}
-				} );
-			} );
+			done();
 		} );
 
 		const image = doc.getRoot().getChild( 0 );