瀏覽代碼

Tests: Added tests for complete icon.

Oskar Wróbel 7 年之前
父節點
當前提交
9479ce193e

+ 1 - 1
packages/ckeditor5-image/src/imageupload/imageuploadprogress.js

@@ -101,7 +101,7 @@ export default class ImageUploadProgress extends Plugin {
 			return;
 		}
 
-		if ( status == 'complete' ) {
+		if ( status == 'complete' && fileRepository.loaders.get( uploadId ) ) {
 			_showCompleteIcon( viewFigure, viewWriter, editor.editing.view );
 		}
 

+ 14 - 3
packages/ckeditor5-image/tests/imageupload/imageuploadprogress.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals window */
+/* globals window, setTimeout */
 
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
 
@@ -179,7 +179,9 @@ describe( 'ImageUploadProgress', () => {
 		nativeReaderMock.mockSuccess( base64Sample );
 	} );
 
-	it( 'should convert image\'s "complete" uploadStatus attribute', done => {
+	it( 'should convert image\'s "complete" uploadStatus attribute and display temporary icon', done => {
+		const clock = testUtils.sinon.useFakeTimers();
+
 		setModelData( model, '<paragraph>[]foo</paragraph>' );
 		editor.execute( 'imageUpload', { file: createNativeFileMock() } );
 
@@ -188,6 +190,15 @@ describe( 'ImageUploadProgress', () => {
 				expect( getViewData( view ) ).to.equal(
 					'[<figure class="ck-widget image" contenteditable="false">' +
 						'<img src="image.png"></img>' +
+						'<div class="ck-image-upload-finish"></div>' +
+					'</figure>]<p>foo</p>'
+				);
+
+				clock.tick( 3000 );
+
+				expect( getViewData( view ) ).to.equal(
+					'[<figure class="ck-widget image" contenteditable="false">' +
+						'<img src="image.png"></img>' +
 					'</figure>]<p>foo</p>'
 				);
 
@@ -227,7 +238,7 @@ describe( 'ImageUploadProgress', () => {
 		);
 	} );
 
-	it( 'should not show progress bar if there is no loader with given uploadId', () => {
+	it( 'should not show progress bar and complete icon if there is no loader with given uploadId', () => {
 		setModelData( model, '<image uploadId="123" uploadStatus="reading"></image>' );
 
 		const image = document.getRoot().getChild( 0 );