Skip to content

Partly revert cloning changes and fix tests #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var SELF = wb.datamodel.List = util.inherit(
this._assertIsItem( items[i] );
}

this._items = items;
this._items = items.slice();
this.length = items.length;
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ var SELF = wb.datamodel.Map = function WbDataModelMap( ItemConstructor, map ) {
}

this._ItemConstructor = ItemConstructor;
this._items = {};

for( var key in map ) {
this._assertIsItem( map[key] );
this.length++;
this._items[key] = map[key];
}

this._items = map;
};

$.extend( SELF.prototype, {
Expand Down
1 change: 1 addition & 0 deletions src/Set.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var SELF = wb.datamodel.Set = util.inherit(
throw new Error( 'There may only be one item per item key' );
}

this.length++;
this._items[key] = items[i];
}
},
Expand Down
19 changes: 4 additions & 15 deletions tests/Group.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ QUnit.test( 'Constructor', function( assert ) {
} );

QUnit.test( 'setItemContainer() & getItemContainer()', function( assert ) {
assert.expect( 6 );
assert.expect( 4 );
var container = getTestContainer( 'key', 1 ),
group = createGroup( 'key', container ),
newContainer = getTestContainer( 'key', 3 );
Expand All @@ -187,22 +187,11 @@ QUnit.test( 'setItemContainer() & getItemContainer()', function( assert ) {
'Verified returned container matching returned container.'
);

container.addItem( getTestItems( 'key', 2 )[1] );

assert.ok(
!group.getItemContainer().equals( container ),
'Group container does not match original container manipulated after Group instantiation.'
);

assert.ok(
!group.getItemContainer().equals( newContainer ),
'Verified returned container not matching not yet set new container.'
);

group.setItemContainer( newContainer );

assert.ok(
group.getItemContainer().equals( newContainer ),
assert.strictEqual(
newContainer,
group.getItemContainer(),
'Set new container.'
);

Expand Down
6 changes: 3 additions & 3 deletions tests/List.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function getTestItems( n ) {
}

QUnit.test( 'Constructor', function( assert ) {
assert.expect( 5 );
assert.expect( 6 );
assert.ok(
( new wb.datamodel.List( TestItem ) ) instanceof wb.datamodel.List,
'Instantiated empty List.'
Expand All @@ -44,10 +44,10 @@ QUnit.test( 'Constructor', function( assert ) {
'Instantiated filled List.'
);

assert.strictEqual(
assert.notStrictEqual(
items,
list._items,
'Constructor does not clone.'
'Constructor does clone.'
);

assert.equal(
Expand Down
6 changes: 3 additions & 3 deletions tests/Map.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function createMap( map ) {
}

QUnit.test( 'Constructor', function( assert ) {
assert.expect( 7 );
assert.expect( 8 );
assert.ok(
createMap() instanceof wb.datamodel.Map,
'Instantiated empty Map.'
Expand All @@ -60,10 +60,10 @@ QUnit.test( 'Constructor', function( assert ) {
'Instantiated filled Map.'
);

assert.strictEqual(
assert.notStrictEqual(
items,
map._items,
'Constructor does not clone.'
'Constructor does clone.'
);

assert.equal(
Expand Down
2 changes: 1 addition & 1 deletion tests/MultiTerm.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ QUnit.test( 'Constructor (positive)', function( assert ) {
} );

QUnit.test( 'Constructor (negative)', function( assert ) {
assert.expect( 4 );
assert.expect( 5 );
var negativeTestSets = [
[undefined, []],
['', undefined],
Expand Down
2 changes: 1 addition & 1 deletion tests/Set.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function createSet( items ) {
}

QUnit.test( 'Constructor', function( assert ) {
assert.expect( 7 );
assert.expect( 8 );
assert.ok(
createSet() instanceof wb.datamodel.Set,
'Instantiated empty Set.'
Expand Down
2 changes: 1 addition & 1 deletion tests/Term.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ QUnit.test( 'Constructor (positive)', function( assert ) {
} );

QUnit.test( 'Constructor (negative)', function( assert ) {
assert.expect( 4 );
assert.expect( 5 );
function instantiateObject( languageCode, text ) {
return function() {
return new wb.datamodel.Term( languageCode, text );
Expand Down