浏览代码

Added missing clearing pending action after upload.

Oskar Wróbel 7 年之前
父节点
当前提交
0aefe7cb66
共有 2 个文件被更改,包括 15 次插入0 次删除
  1. 1 0
      packages/ckeditor5-upload/src/filerepository.js
  2. 14 0
      packages/ckeditor5-upload/tests/filerepository.js

+ 1 - 0
packages/ckeditor5-upload/src/filerepository.js

@@ -245,6 +245,7 @@ export default class FileRepository extends Plugin {
 			}
 			}
 		} else {
 		} else {
 			pendingActions.remove( this._pendingAction );
 			pendingActions.remove( this._pendingAction );
+			this._pendingAction = null;
 		}
 		}
 	}
 	}
 }
 }

+ 14 - 0
packages/ckeditor5-upload/tests/filerepository.js

@@ -153,6 +153,20 @@ describe( 'FileRepository', () => {
 
 
 			expect( Array.from( pendingActions )[ 0 ] ).to.have.property( 'message', 'Upload in progress 30%.' );
 			expect( Array.from( pendingActions )[ 0 ] ).to.have.property( 'message', 'Upload in progress 30%.' );
 		} );
 		} );
+
+		it( 'should add pending action correctly when one upload is after another', () => {
+			const loader1 = fileRepository.createLoader( createNativeFileMock() );
+
+			expect( pendingActions.first ).to.have.property( 'message', 'Upload in progress 0%.' );
+
+			fileRepository.destroyLoader( loader1 );
+
+			expect( pendingActions.first ).to.null;
+
+			fileRepository.createLoader( createNativeFileMock() );
+
+			expect( pendingActions.first ).to.have.property( 'message', 'Upload in progress 0%.' );
+		} );
 	} );
 	} );
 
 
 	describe( 'createLoader()', () => {
 	describe( 'createLoader()', () => {