Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Before doing matching for object - object. Check that object have pro…
Browse files Browse the repository at this point in the history
…perty
  • Loading branch information
btd committed Aug 13, 2015
1 parent 6575ec3 commit fcc4918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ext/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = function(should, Assertion) {

util.forEach(other, function(value, key) {
try {
should(this.obj[key]).match(value);
should(this.obj).have.property(key).which.match(value);
matchedProps.push(util.formatProp(key));
} catch(e) {
if(e instanceof should.AssertionError) {
Expand Down
4 changes: 4 additions & 0 deletions test/ext/match.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ describe('match', function() {
}, 'expected Array [ 10, 11 ] to match each 10\n expected 11 to match 10');
});

it('test matchAny(obj)', function() {
[{}, {nested: {prop: 'foo'}}].should.matchAny( {nested: {prop: 'foo'}} );
});

it('test matchAny(function)', function() {
[9, 10, 11].should.matchAny(function(it) {
return it >= 10;
Expand Down

0 comments on commit fcc4918

Please sign in to comment.