diff --git a/lib/nodemock.js b/lib/nodemock.js index 541a7d8..bebdcf1 100644 --- a/lib/nodemock.js +++ b/lib/nodemock.js @@ -354,7 +354,7 @@ function NodeMock(methodName) { continue; } else if(actualType == "object") { if(!deepObjectCheck(expected[key] ,actual[key])) return false; - } else { + } else if (!isNaN(actual[key]) && !isNaN(expected[key])) { if(actual[key] != expected[key]) return false; } } diff --git a/package.json b/package.json index 8be60b1..d4edd66 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,14 @@ { "name": "nodemock", - "version": "0.3.4", + "version": "0.3.5", "directories": { "test": "test" }, "main": "./lib/nodemock", "description": "Simple Yet Powerful Mocking Framework for NodeJs", - "author": "Arunoda Susiripala ", + "author": "Curtis Schlak ", "homepage": "http://curtis.schlak.com/nodemock/", "contributors": [ - "Curtis Schlak ", "Oscar Renalias ", "Aaron Fay ", "Dominic Tarr ", @@ -26,10 +25,10 @@ } ], "devDependencies": { - "grunt": "~0.4.2", - "grunt-contrib-jshint": "~0.3.0", - "grunt-contrib-nodeunit": "~0.1.2", - "nodeunit": "~0.7.4" + "grunt": "^0.4.5", + "grunt-contrib-jshint": "^0.11.3", + "grunt-contrib-nodeunit": "^0.4.1", + "nodeunit": "^0.9.1" }, "repository": { "type": "git", @@ -52,5 +51,5 @@ "nodemock", "mockingbird" ], - "license": "MIT-License" + "license": "MIT" } diff --git a/test/nodemock.js b/test/nodemock.js index 844691e..6406846 100644 --- a/test/nodemock.js +++ b/test/nodemock.js @@ -42,17 +42,28 @@ exports['mocks can have names which get reported in error messages'] = function( exports['mocked functions pattern match on'] = { setUp: function(cb) { this.mock = nm.mock('foo') - .takes(10, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + .takes(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); cb(); } , numbers: function(test) { var mock = this.mock; test.doesNotThrow(function() { - mock.foo(10, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.throws(function() { - mock.foo(-1, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(-1, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + }); + test.done(); + } + +, 'silly numbers': function(test) { + var mock = this.mock; + test.doesNotThrow(function() { + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + }); + test.throws(function() { + mock.foo(10, 3, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.done(); } @@ -60,10 +71,10 @@ exports['mocked functions pattern match on'] = { , strings: function(test) { var mock = this.mock; test.doesNotThrow(function() { - mock.foo(10, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.throws(function() { - mock.foo(10, "WORLD", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "WORLD", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.done(); } @@ -71,10 +82,10 @@ exports['mocked functions pattern match on'] = { , booleans: function(test) { var mock = this.mock; test.doesNotThrow(function() { - mock.foo(10, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.throws(function() { - mock.foo(10, "Hello", false, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", false, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.done(); } @@ -82,10 +93,10 @@ exports['mocked functions pattern match on'] = { , arrays: function(test) { var mock = this.mock; test.doesNotThrow(function() { - mock.foo(10, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.throws(function() { - mock.foo(10, "Hello", true, [1, 5, 4], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", true, [1, 5, 4], {"a": "aa", "b": "bb"}); }); test.done(); } @@ -93,10 +104,10 @@ exports['mocked functions pattern match on'] = { , objects: function(test) { var mock = this.mock; test.doesNotThrow(function() { - mock.foo(10, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"a": "aa", "b": "bb"}); }); test.throws(function() { - mock.foo(10, "Hello", true, [1, 4, 5], {"c": "aa", "b": "aa"}); + mock.foo(10, NaN, "Hello", true, [1, 4, 5], {"c": "aa", "b": "aa"}); }); test.done(); }