Comparing version 0.2.0beta to 0.2.1beta
@@ -35,2 +35,3 @@ /** | ||
var callbackArgs = []; | ||
var shouldFail = []; | ||
@@ -42,3 +43,6 @@ var mockFunction = function(method) { | ||
if(!this[method]) { | ||
if(shouldFail[method]) { | ||
throw "You should not call anymethod on this object"; | ||
} else if(!this[method]) { | ||
throw "Mock function '" + method + "()' is not defined"; | ||
@@ -115,2 +119,11 @@ | ||
/** | ||
* After this call when someone calls on this this object is'll | ||
* throw an exception | ||
*/ | ||
this.fail = function() { | ||
shouldFail[currentMockFunction] = true; | ||
return this; | ||
}; | ||
var deepObjectCheck = function(expected, actual) { | ||
@@ -148,2 +161,6 @@ | ||
}; | ||
exports.fail = function() { | ||
return {}; | ||
}; | ||
} |
{ | ||
"name": "nodemock", | ||
"version": "0.2.0beta", | ||
"version": "0.2.1beta", | ||
"directories": { | ||
@@ -8,9 +8,12 @@ "lib": "./lib" | ||
"main": "./lib/nodemock", | ||
"engines": { | ||
"node" : ">=0.2.0" | ||
}, | ||
"description": "Simple Yet Powerful Mocking Framework for NodeJs", | ||
"author": "Arunoda Susiripala <arunoda.susiripala@gmail.com>", | ||
"homepage": "https://github.com/arunoda/nodemock", | ||
"license": "The MIT License", | ||
"licenses": [ | ||
{ | ||
"type": "The MIT License", | ||
"url": "http://www.opensource.org/licenses/mit-license.php" | ||
} | ||
], | ||
"repository" : | ||
@@ -17,0 +20,0 @@ { |
@@ -229,2 +229,25 @@ /** | ||
test.done(); | ||
}; | ||
exports.testFailNoAnyMockMethod = function(test) { | ||
var mock = nm.fail(); | ||
test.throws(function() { | ||
mock.foo(); | ||
}); | ||
test.done(); | ||
}; | ||
exports.testFailOneMockMethod = function(test) { | ||
var mock = nm.mock("foo").fail(); | ||
mock.mock("bar").takes(10, 20); | ||
test.throws(function() { | ||
mock.foo(); | ||
}); | ||
test.doesNotThrow(function() { | ||
mock.bar(10, 20); | ||
}); | ||
test.done(); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
14762
0
305