diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 2daf10bac..41b647ccf 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -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; } } diff --git a/test/assert.js b/test/assert.js index d8d3db01a..f2fbd3de7 100644 --- a/test/assert.js +++ b/test/assert.js @@ -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' ]); diff --git a/test/expect.js b/test/expect.js index 1fecf02b7..13cc9a44e 100644 --- a/test/expect.js +++ b/test/expect.js @@ -1568,6 +1568,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'); diff --git a/test/should.js b/test/should.js index 612f74e90..cbb3902a4 100644 --- a/test/should.js +++ b/test/should.js @@ -1369,6 +1369,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');