8
0
Эх сурвалжийг харах

Extended View class tests with child collection management test cases.

Aleksander Nowodzinski 9 жил өмнө
parent
commit
e1bb03e5f8

+ 1 - 0
packages/ckeditor5-ui/src/view.js

@@ -66,6 +66,7 @@ export default class View {
 		// accordingly, initialize (or not) children views as they are added in the future.
 		this._viewCollections.on( 'add', ( evt, collection ) => {
 			collection.bind( 'ready' ).to( this );
+			collection.locale = locale;
 		} );
 
 		// Once the collection is removed from the view, the {@link ui.View#ready} binding

+ 32 - 0
packages/ckeditor5-ui/tests/view.js

@@ -43,6 +43,38 @@ describe( 'View', () => {
 			expect( view.locale ).to.equal( locale );
 			expect( view.t ).to.equal( locale.t );
 		} );
+
+		it( 'handles #ready binding of instances in #_viewCollections', () => {
+			const collection = new ViewCollection();
+
+			expect( collection.ready ).to.be.false;
+
+			view._viewCollections.add( collection );
+			expect( collection.ready ).to.be.false;
+
+			view.ready = true;
+			expect( collection.ready ).to.be.true;
+
+			view._viewCollections.remove( collection );
+
+			view.ready = false;
+			expect( collection.ready ).to.be.true;
+		} );
+
+		it( 'handles #locale of instances in #_viewCollections', () => {
+			const locale = {
+				t() {}
+			};
+
+			const view = new View( locale );
+			const collection = new ViewCollection();
+
+			expect( view.locale ).to.equal( locale );
+			expect( collection.locale ).to.be.undefined;
+
+			view._viewCollections.add( collection );
+			expect( collection.locale ).to.equal( view.locale );
+		} );
 	} );
 
 	describe( 'createCollection', () => {