Skip to content

Commit

Permalink
cleaned up ambiguous unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
obeliskos committed May 18, 2018
1 parent 46a3411 commit 13fdaa5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spec/generic/unique.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,22 @@ describe('Constraints', function () {

collection.findAndRemove();

// implicitly 'expecting' that this will not throw exception on Duplicate key for property name: Sleipnir
// reinsert 2 of the 3 original docs
// implicitly 'expecting' that this will not throw exception on Duplicate key for property name(s)
collection.insert(JSON.parse(JSON.stringify(data[0])));
collection.insert(JSON.parse(JSON.stringify(data[1])));

var keys = Object.keys(collection.constraints.unique.name.keyMap);
expect(keys.length).toEqual(3);
keys.sort();
// seems we don't delete the key but set its value to undefined
expect(keys[0]).toEqual('Hel');
expect(typeof collection.constraints.unique["name"].keyMap['Hel'] === 'undefined').toEqual(true);
// the rest were re-added so they should not only exist but be undefined
expect(keys[1]).toEqual('Jormungandr');
expect(typeof collection.constraints.unique["name"].keyMap['Jormungandr'] === 'undefined').toEqual(false);
expect(keys[2]).toEqual('Sleipnir');
expect(typeof collection.constraints.unique["name"].keyMap['Sleipnir'] === 'undefined').toEqual(false);
});

it('chained batch updates should update constraints', function() {
Expand Down

0 comments on commit 13fdaa5

Please sign in to comment.