8
0
Quellcode durchsuchen

Tests: Added tests to various Views to make sure they are safe to destroy multiple times.

Aleksander Nowodzinski vor 8 Jahren
Ursprung
Commit
ef52117d90

+ 10 - 0
packages/ckeditor5-ui/tests/editableui/editableuiview.js

@@ -85,6 +85,16 @@ describe( 'EditableUIView', () => {
 			} );
 		} );
 
+		it( 'can be called multiple times', done => {
+			expect( () => {
+				view.destroy().then( () => {
+					return view.destroy().then( () => {
+						done();
+					} );
+				} );
+			} ).to.not.throw();
+		} );
+
 		describe( 'when #editableElement as an argument', () => {
 			it( 'reverts contentEditable property of editableElement (was false)', () => {
 				editableElement = document.createElement( 'div' );

+ 10 - 0
packages/ckeditor5-ui/tests/editorui/editoruiview.js

@@ -51,5 +51,15 @@ describe( 'EditorUIView', () => {
 				expect( el.parentNode ).to.be.null;
 			} );
 		} );
+
+		it( 'can be called multiple times', done => {
+			expect( () => {
+				view.destroy().then( () => {
+					return view.destroy().then( () => {
+						done();
+					} );
+				} );
+			} ).to.not.throw();
+		} );
 	} );
 } );

+ 7 - 0
packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

@@ -291,6 +291,13 @@ describe( 'ContextualToolbar', () => {
 	} );
 
 	describe( 'destroy()', () => {
+		it( 'can be called multiple times', () => {
+			expect( () => {
+				contextualToolbar.destroy();
+				contextualToolbar.destroy();
+			} ).to.not.throw();
+		} );
+
 		it( 'should not fire `_selectionChangeDebounced` after plugin destroy', done => {
 			const spy = sandbox.spy();
 

+ 10 - 0
packages/ckeditor5-ui/tests/toolbar/sticky/stickytoolbarview.js

@@ -178,6 +178,16 @@ describe( 'StickyToolbarView', () => {
 			expect( view.destroy() ).to.be.instanceof( Promise );
 		} );
 
+		it( 'can be called multiple times', done => {
+			expect( () => {
+				view.destroy().then( () => {
+					return view.destroy().then( () => {
+						done();
+					} );
+				} );
+			} ).to.not.throw();
+		} );
+
 		it( 'calls destroy on parent class', () => {
 			const spy = testUtils.sinon.spy( ToolbarView.prototype, 'destroy' );