Skip to content

Commit

Permalink
Merge pull request #924 from meeber/fix-not-have-keys
Browse files Browse the repository at this point in the history
fix: make negated `.keys` consider size of sets
  • Loading branch information
keithamus committed Mar 23, 2017
2 parents a7e1200 + f37d2c2 commit 011612c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ module.exports = function (chai, _) {
});
});

if (!flag(this, 'negate') && !flag(this, 'contains')) {
if (!flag(this, 'contains')) {
ok = ok && keys.length == actual.length;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ describe('assert', function () {
assert.containsAllKeys({ foo: 1, bar: 2 }, { 'bar': 7, 'foo': 6 });

assert.doesNotHaveAllKeys({ foo: 1, bar: 2 }, [ 'baz' ]);
assert.doesNotHaveAllKeys({ foo: 1, bar: 2 }, [ 'foo' ]);
assert.doesNotHaveAllKeys({ foo: 1, bar: 2 }, [ 'foo', 'baz' ]);
assert.doesNotHaveAllKeys({ foo: 1, bar: 2, baz: 3 }, [ 'foo', 'bar', 'baz', 'fake' ]);
assert.doesNotHaveAllKeys({ foo: 1, bar: 2 }, [ 'baz', 'foo' ]);
Expand Down
1 change: 1 addition & 0 deletions test/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@ describe('expect', function () {
expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);

expect({ foo: 1, bar: 2 }).to.not.have.keys('baz');
expect({ foo: 1, bar: 2 }).to.not.have.keys('foo');
expect({ foo: 1, bar: 2 }).to.not.have.keys('foo', 'baz');
expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz');
expect({ foo: 1, bar: 2 }).to.not.contain.keys('foo', 'baz');
Expand Down
1 change: 1 addition & 0 deletions test/should.js
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ describe('should', function() {
({ foo: 1, bar: 2 }).should.contain.keys({ 'foo': 6 });

({ foo: 1, bar: 2 }).should.not.have.keys('baz');
({ foo: 1, bar: 2 }).should.not.have.keys('foo');
({ foo: 1, bar: 2 }).should.not.have.keys('foo', 'baz');
({ foo: 1, bar: 2 }).should.not.contain.keys('baz');
({ foo: 1, bar: 2 }).should.not.contain.keys('foo', 'baz');
Expand Down

0 comments on commit 011612c

Please sign in to comment.