Skip to content

Commit

Permalink
v1.0.2 - Updated unit tests to pass on Node 0.10 and 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
James Greene authored and James Greene committed Apr 1, 2016
1 parent 0b6bf7d commit ac3f698
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "chai-deep-match",
"version": "1.0.1",
"version": "1.0.2",
"description": "Extends Chai with an assertion for deeply matching objects (i.e. subset equality checking)",
"author": {
"name": "James M. Greene",
Expand Down Expand Up @@ -32,6 +32,9 @@
"scripts": {
"test": "grunt travis --verbose"
},
"engines": {
"node": ">=0.10"
},
"peerDependencies": {
"chai": ">=2.1.2 <4"
},
Expand Down
25 changes: 15 additions & 10 deletions test/index.spec.js
Expand Up @@ -14,17 +14,22 @@ var deepObj = {
e: 'baz'
};

// Node 4.x & 5.x: "re.exec is not a function"
// Node 12.x: "undefined is not a function"
// Node 10.x: "Object #<Object> has no method 'exec'"
var mismatchedMatchRegex = /(?:(?:re\.exec|undefined) is not a function|Object #<Object> has no method 'exec')/;



describe( 'chai-deep-match', function() {

it( 'should not automatically plug into chai', function() {
expect( 'awesome stringification' ).to.match( /some string/ );
expect( 'awesome stringification' ).to.deep.match( /some string/ );
expect( function() { expect( deepObj ).to.match( deepObj ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.match( { e: 'baz' } ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.deep.match( deepObj ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.deep.match( { e: 'baz' } ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.match( deepObj ); } ).to.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.match( { e: 'baz' } ); } ).to.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.deep.match( deepObj ); } ).to.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.deep.match( { e: 'baz' } ); } ).to.throw( TypeError, mismatchedMatchRegex );
});


Expand All @@ -37,16 +42,16 @@ describe( 'chai-deep-match', function() {
// Assert
expect( 'awesome stringification' ).to.match( /some string/ );
expect( 'awesome stringification' ).to.deep.match( /some string/ );
expect( function() { expect( deepObj ).to.match( deepObj ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.match( { e: 'baz' } ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.deep.match( deepObj ); } ).to.not.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.deep.match( { e: 'baz' } ); } ).to.not.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.match( deepObj ); } ).to.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.match( { e: 'baz' } ); } ).to.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.deep.match( deepObj ); } ).to.not.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.deep.match( { e: 'baz' } ); } ).to.not.throw( TypeError, mismatchedMatchRegex );
});

it( 'should not interfere with the non-deep `match` assertion', function() {
expect( 'awesome stringification' ).to.match( /some string/ );
expect( function() { expect( deepObj ).to.match( deepObj ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.match( { e: 'baz' } ); } ).to.throw( TypeError, /re\.exec is not a function/ );
expect( function() { expect( deepObj ).to.match( deepObj ); } ).to.throw( TypeError, mismatchedMatchRegex );
expect( function() { expect( deepObj ).to.match( { e: 'baz' } ); } ).to.throw( TypeError, mismatchedMatchRegex );
});

it( 'should not interfere with the former deep `match` assertion behavior (which ignores "deep") if the second argument is a RegExp', function() {
Expand Down

0 comments on commit ac3f698

Please sign in to comment.