Skip to content

Commit

Permalink
test: added custom message test to negated .nested-, .deep-, .own.inc…
Browse files Browse the repository at this point in the history
…lude
  • Loading branch information
zetamorph committed May 4, 2017
1 parent 4180242 commit 33e4403
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
4 changes: 2 additions & 2 deletions test/assert.js
Expand Up @@ -744,8 +744,8 @@ describe('assert', function () {
}, "blah: expected { foo: { a: 1 }, bar: { b: 2 } } to have deep property 'bar' of { b: 9 }, but got { b: 2 }");

err(function () {
assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 2}});
}, "expected { foo: { a: 1 }, bar: { b: 2 } } to not have deep property 'foo' of { a: 1 }");
assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 2}}, 'blah');
}, "blah: expected { foo: { a: 1 }, bar: { b: 2 } } to not have deep property 'foo' of { a: 1 }");
});

it('nestedInclude and notNestedInclude', function() {
Expand Down
40 changes: 28 additions & 12 deletions test/expect.js
Expand Up @@ -1797,16 +1797,16 @@ describe('expect', function () {
}, "blah: expected [ { a: 1 }, { b: 2 } ] to deep include { a: 9 }");

err(function () {
expect([obj1, obj2]).to.not.deep.include({a: 1});
}, "expected [ { a: 1 }, { b: 2 } ] to not deep include { a: 1 }");
expect([obj1, obj2], 'blah').to.not.deep.include({a: 1});
}, "blah: expected [ { a: 1 }, { b: 2 } ] to not deep include { a: 1 }");

err(function () {
expect({foo: obj1, bar: obj2}).to.deep.include({foo: {a: 1}, bar: {b: 9}});
}, "expected { foo: { a: 1 }, bar: { b: 2 } } to have deep property 'bar' of { b: 9 }, but got { b: 2 }");

err(function () {
expect({foo: obj1, bar: obj2}).to.not.deep.include({foo: {a: 1}, bar: {b: 2}});
}, "expected { foo: { a: 1 }, bar: { b: 2 } } to not have deep property 'foo' of { a: 1 }");
expect({foo: obj1, bar: obj2}).to.not.deep.include({foo: {a: 1}, bar: {b: 2}}, 'blah');
}, "blah: expected { foo: { a: 1 }, bar: { b: 2 } } to not have deep property 'foo' of { a: 1 }");
});

it('nested.include()', function () {
Expand All @@ -1832,8 +1832,12 @@ describe('expect', function () {
}, "expected { a: { b: [ 'x', 'y' ] } } to have nested property 'a.c'");

err(function () {
expect({a: {b: ['x', 'y']}}).to.not.nested.include({'a.b[1]': 'y'});
}, "expected { a: { b: [ 'x', 'y' ] } } to not have nested property 'a.b[1]' of 'y'");
expect({a: {b: ['x', 'y']}}).to.not.nested.include({'a.b[1]': 'y'}, 'blah');
}, "blah: expected { a: { b: [ 'x', 'y' ] } } to not have nested property 'a.b[1]' of 'y'");

err(function () {
expect({a: {b: ['x', 'y']}}, 'blah').to.not.nested.include({'a.b[1]': 'y'});
}, "blah: expected { a: { b: [ 'x', 'y' ] } } to not have nested property 'a.b[1]' of 'y'");
});

it('deep.nested.include()', function () {
Expand All @@ -1859,8 +1863,12 @@ describe('expect', function () {
}, "expected { a: { b: [ [Object] ] } } to have deep nested property 'a.c'");

err(function () {
expect({a: {b: [{x: 1}]}}).to.not.deep.nested.include({'a.b[0]': {x: 1}});
}, "expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
expect({a: {b: [{x: 1}]}}).to.not.deep.nested.include({'a.b[0]': {x: 1}}, 'blah');
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");

err(function () {
expect({a: {b: [{x: 1}]}}, 'blah').to.not.deep.nested.include({'a.b[0]': {x: 1}});
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
});

it('own.include()', function () {
Expand All @@ -1883,8 +1891,12 @@ describe('expect', function () {
}, "expected { a: 1 } to have own property 'toString'");

err(function () {
expect({a: 1}).to.not.own.include({a: 1});
}, "expected { a: 1 } to not have own property 'a' of 1");
expect({a: 1}).to.not.own.include({a: 1}, 'blah');
}, "blah: expected { a: 1 } to not have own property 'a' of 1");

err(function () {
expect({a: 1}, 'blah').to.not.own.include({a: 1});
}, "blah: expected { a: 1 } to not have own property 'a' of 1");
});

it('deep.own.include()', function () {
Expand All @@ -1906,8 +1918,12 @@ describe('expect', function () {
}, "expected { a: { b: 2 } } to have deep own property 'toString'");

err(function () {
expect({a: {b: 2}}).to.not.deep.own.include({a: {b: 2}});
}, "expected { a: { b: 2 } } to not have deep own property 'a' of { b: 2 }");
expect({a: {b: 2}}).to.not.deep.own.include({a: {b: 2}}, 'blah');
}, "blah: expected { a: { b: 2 } } to not have deep own property 'a' of { b: 2 }");

err(function () {
expect({a: {b: 2}}, 'blah').to.not.deep.own.include({a: {b: 2}});
}, "blah: expected { a: { b: 2 } } to not have deep own property 'a' of { b: 2 }");
});

it('keys(array|Object|arguments)', function(){
Expand Down
20 changes: 10 additions & 10 deletions test/should.js
Expand Up @@ -1426,8 +1426,8 @@ describe('should', function() {
}, "expected { foo: { a: 1 }, bar: { b: 2 } } to have deep property 'bar' of { b: 9 }, but got { b: 2 }");

err(function () {
({foo: obj1, bar: obj2}).should.not.deep.include({foo: {a: 1}, bar: {b: 2}});
}, "expected { foo: { a: 1 }, bar: { b: 2 } } to not have deep property 'foo' of { a: 1 }");
({foo: obj1, bar: obj2}).should.not.deep.include({foo: {a: 1}, bar: {b: 2}}, 'blah');
}, "blah: expected { foo: { a: 1 }, bar: { b: 2 } } to not have deep property 'foo' of { a: 1 }");
});

it('nested.include()', function () {
Expand All @@ -1449,8 +1449,8 @@ describe('should', function() {
}, "expected { a: { b: [ 'x', 'y' ] } } to have nested property 'a.c'");

err(function () {
({a: {b: ['x', 'y']}}).should.not.nested.include({'a.b[1]': 'y'});
}, "expected { a: { b: [ 'x', 'y' ] } } to not have nested property 'a.b[1]' of 'y'");
({a: {b: ['x', 'y']}}).should.not.nested.include({'a.b[1]': 'y'}, 'blah');
}, "blah: expected { a: { b: [ 'x', 'y' ] } } to not have nested property 'a.b[1]' of 'y'");
});

it('deep.nested.include()', function () {
Expand All @@ -1472,8 +1472,8 @@ describe('should', function() {
}, "expected { a: { b: [ [Object] ] } } to have deep nested property 'a.c'");

err(function () {
({a: {b: [{x: 1}]}}).should.not.deep.nested.include({'a.b[0]': {x: 1}});
}, "expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
({a: {b: [{x: 1}]}}).should.not.deep.nested.include({'a.b[0]': {x: 1}}, 'blah');
}, "blah: expected { a: { b: [ [Object] ] } } to not have deep nested property 'a.b[0]' of { x: 1 }");
});

it('own.include()', function () {
Expand All @@ -1492,8 +1492,8 @@ describe('should', function() {
}, "expected { a: 1 } to have own property 'toString'");

err(function () {
({a: 1}).should.not.own.include({a: 1});
}, "expected { a: 1 } to not have own property 'a' of 1");
({a: 1}).should.not.own.include({a: 1}, 'blah');
}, "blah: expected { a: 1 } to not have own property 'a' of 1");
});

it('deep.own.include()', function () {
Expand All @@ -1511,8 +1511,8 @@ describe('should', function() {
}, "expected { a: { b: 2 } } to have deep own property 'toString'");

err(function () {
({a: {b: 2}}).should.not.deep.own.include({a: {b: 2}});
}, "expected { a: { b: 2 } } to not have deep own property 'a' of { b: 2 }");
({a: {b: 2}}).should.not.deep.own.include({a: {b: 2}}, 'blah');
}, "blah: expected { a: { b: 2 } } to not have deep own property 'a' of { b: 2 }");
});

it('keys(array|Object|arguments)', function(){
Expand Down

0 comments on commit 33e4403

Please sign in to comment.