Browse Source

Tests: Added tests for Controller#addCollection() method.

Aleksander Nowodzinski 9 years ago
parent
commit
1b2bd80c1e
1 changed files with 27 additions and 0 deletions
  1. 27 0
      packages/ckeditor5-ui/tests/controller.js

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

@@ -406,6 +406,33 @@ describe( 'Controller', () => {
 				} );
 		} );
 	} );
+
+	describe( 'addCollection', () => {
+		it( 'should add a new collection', () => {
+			const controller = new Controller();
+
+			controller.addCollection( 'foo' );
+
+			expect( controller.collections ).to.have.length( 1 );
+			expect( controller.collections.get( 'foo' ).name ).to.equal( 'foo' );
+		} );
+
+		it( 'should return the collection which has been created (chaining)', () => {
+			const controller = new Controller();
+			const returned = controller.addCollection( 'foo' );
+
+			expect( returned ).to.be.instanceOf( ControllerCollection );
+		} );
+
+		it( 'should pass locale to controller collection', () => {
+			const controller = new Controller();
+			const locale = {};
+
+			controller.addCollection( 'foo', locale );
+
+			expect( controller.collections.get( 'foo' ).locale ).to.equal( locale );
+		} );
+	} );
 } );
 
 function defineParentViewClass() {