Jelajahi Sumber

Tests: Added test to check if child controlers in anonymous collection are destroyed correctly.

Aleksander Nowodzinski 9 tahun lalu
induk
melakukan
07fe0aa3f8
1 mengubah file dengan 20 tambahan dan 0 penghapusan
  1. 20 0
      packages/ckeditor5-ui/tests/controller.js

+ 20 - 0
packages/ckeditor5-ui/tests/controller.js

@@ -443,6 +443,26 @@ describe( 'Controller', () => {
 				} );
 		} );
 
+		it( 'should destroy child controllers in anonymous collection along with their views', () => {
+			const parentController = new ParentController( null, new ParentView() );
+			const childView = new View();
+			const childController = new Controller( null, childView );
+			const spy = testUtils.sinon.spy( childView, 'destroy' );
+
+			parentController.add( childController );
+
+			return parentController.init()
+				.then( () => {
+					return parentController.destroy();
+				} )
+				.then( () => {
+					sinon.assert.calledOnce( spy );
+					expect( childController.model ).to.be.null;
+					expect( childController.view ).to.be.null;
+					expect( childController.collections ).to.be.null;
+				} );
+		} );
+
 		// See #11
 		it( 'should correctly destroy multiple controller collections', () => {
 			const parentController = new Controller();