|
|
@@ -27,6 +27,7 @@ describe( 'ViewCollection', () => {
|
|
|
expect( collection.ready ).to.be.false;
|
|
|
expect( collection._parentElement ).to.be.null;
|
|
|
expect( collection._boundItemsToViewsMap ).to.be.instanceOf( Map );
|
|
|
+ expect( collection._idProperty ).to.equal( 'viewUid' );
|
|
|
} );
|
|
|
|
|
|
it( 'accepts locale and defines the locale property', () => {
|
|
|
@@ -139,7 +140,7 @@ describe( 'ViewCollection', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'add', () => {
|
|
|
+ describe( 'add()', () => {
|
|
|
it( 'returns a promise', () => {
|
|
|
expect( collection.add( {} ) ).to.be.instanceof( Promise );
|
|
|
} );
|
|
|
@@ -169,6 +170,17 @@ describe( 'ViewCollection', () => {
|
|
|
} );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'works for a view with a Number view#id attribute', () => {
|
|
|
+ const view = new View();
|
|
|
+
|
|
|
+ view.set( 'id', 1 );
|
|
|
+
|
|
|
+ return collection.add( view ).then( () => {
|
|
|
+ expect( view.id ).to.equal( 1 );
|
|
|
+ expect( view.viewUid ).to.be.a( 'string' );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'setParent', () => {
|
|
|
@@ -181,7 +193,7 @@ describe( 'ViewCollection', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'bindTo', () => {
|
|
|
+ describe( 'bindTo()', () => {
|
|
|
class ViewClass extends View {
|
|
|
constructor( locale, data ) {
|
|
|
super( locale );
|
|
|
@@ -194,14 +206,14 @@ describe( 'ViewCollection', () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- it( 'provides "as" interface', () => {
|
|
|
+ it( 'provides "as()" interface', () => {
|
|
|
const returned = collection.bindTo( {} );
|
|
|
|
|
|
expect( returned ).to.have.keys( 'as' );
|
|
|
expect( returned.as ).to.be.a( 'function' );
|
|
|
} );
|
|
|
|
|
|
- describe( 'as', () => {
|
|
|
+ describe( 'as()', () => {
|
|
|
it( 'does not chain', () => {
|
|
|
const returned = collection.bindTo( new Collection() ).as( ViewClass );
|
|
|
|
|
|
@@ -292,7 +304,7 @@ describe( 'ViewCollection', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'delegate', () => {
|
|
|
+ describe( 'delegate()', () => {
|
|
|
it( 'should throw when event names are not strings', () => {
|
|
|
expect( () => {
|
|
|
collection.delegate();
|
|
|
@@ -311,14 +323,14 @@ describe( 'ViewCollection', () => {
|
|
|
expect( collection.delegate( 'foo' ) ).to.be.an( 'object' );
|
|
|
} );
|
|
|
|
|
|
- it( 'provides "to" interface', () => {
|
|
|
+ it( 'provides "to()" interface', () => {
|
|
|
const delegate = collection.delegate( 'foo' );
|
|
|
|
|
|
expect( delegate ).to.have.keys( 'to' );
|
|
|
expect( delegate.to ).to.be.a( 'function' );
|
|
|
} );
|
|
|
|
|
|
- describe( 'to', () => {
|
|
|
+ describe( 'to()', () => {
|
|
|
it( 'does not chain', () => {
|
|
|
const returned = collection.delegate( 'foo' ).to( {} );
|
|
|
|