Skip to content

Commit

Permalink
Merge pull request #1124 from meeber/fix-deep-equal-stack
Browse files Browse the repository at this point in the history
fix: remove Chai frames from `.deep.equal` stack
  • Loading branch information
astorije committed Jan 15, 2018
2 parents 76c0c16 + 2f46af8 commit c808e11
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/chai/core/assertions.js
Expand Up @@ -1016,7 +1016,10 @@ module.exports = function (chai, _) {
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
if (flag(this, 'deep')) {
return this.eql(val);
var prevLockSsfi = flag(this, 'lockSsfi');
flag(this, 'lockSsfi', true);
this.eql(val);
flag(this, 'lockSsfi', prevLockSsfi);
} else {
this.assert(
val === obj
Expand Down
16 changes: 16 additions & 0 deletions test/expect.js
Expand Up @@ -1181,6 +1181,22 @@ describe('expect', function () {
it('deep.equal(val)', function(){
expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
expect({ foo: 'bar' }).not.to.deep.equal({ foo: 'baz' });

err(function(){
expect({foo: 'bar'}).to.deep.equal({foo: 'baz'}, 'blah');
}, "blah: expected { foo: 'bar' } to deeply equal { foo: 'baz' }");

err(function(){
expect({foo: 'bar'}, 'blah').to.deep.equal({foo: 'baz'});
}, "blah: expected { foo: 'bar' } to deeply equal { foo: 'baz' }");

err(function(){
expect({foo: 'bar'}).to.not.deep.equal({foo: 'bar'}, 'blah');
}, "blah: expected { foo: 'bar' } to not deeply equal { foo: 'bar' }");

err(function(){
expect({foo: 'bar'}, 'blah').to.not.deep.equal({foo: 'bar'});
}, "blah: expected { foo: 'bar' } to not deeply equal { foo: 'bar' }");
});

it('deep.equal(/regexp/)', function(){
Expand Down
13 changes: 13 additions & 0 deletions test/should.js
Expand Up @@ -1022,6 +1022,19 @@ describe('should', function() {
}, "blah: expected '4' to equal 4");
});

it('deep.equal(val)', function(){
({ foo: 'bar' }).should.deep.equal({ foo: 'bar' });
({ foo: 'bar' }).should.not.deep.equal({ foo: 'baz' });

err(function(){
({foo: 'bar'}).should.deep.equal({foo: 'baz'}, 'blah');
}, "blah: expected { foo: 'bar' } to deeply equal { foo: 'baz' }");

err(function(){
({foo: 'bar'}).should.not.deep.equal({foo: 'bar'}, 'blah');
}, "blah: expected { foo: 'bar' } to not deeply equal { foo: 'bar' }");
});

it('empty', function(){
function FakeArgs() {};
FakeArgs.prototype.length = 0;
Expand Down

0 comments on commit c808e11

Please sign in to comment.