Merge pull request #1124 from meeber/fix-deep-equal-stack

fix: remove Chai frames from `.deep.equal` stack
This commit is contained in:
Jérémie Astori 2018-01-14 21:05:10 -05:00 committed by GitHub
commit c808e11ffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View file

@ -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

View file

@ -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(){

View file

@ -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;