Browse files

Fixed issue #12

  fail() throws exception on assertThrows when method was not called
  • Loading branch information...
1 parent b901cfc commit 1a34453ce288c97e9961c907b9702cffb556c1ad @arunoda committed Oct 1, 2011
Showing with 13 additions and 3 deletions.
  1. +1 −1 lib/nodemock.js
  2. +1 −1 package.json
  3. +11 −1 test/nodemock.js
View
2 lib/nodemock.js
@@ -161,7 +161,7 @@ function NodeMock(methodName) {
for(var method in entries) {
var entriesForMethod = entries[method];
entriesForMethod.forEach(function(entry) {
- if(entry.executed == false) {
+ if(!entry.shouldFail && entry.executed == false) {
success = false;
console.error(
"method call for: '" + method + "()' with params: " + getParamString(entry.args) + " was not executed!\n"
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "nodemock",
- "version": "0.2.14",
+ "version": "0.2.15",
"directories": {
"lib": "./lib"
},
View
12 test/nodemock.js
@@ -457,4 +457,14 @@ exports.testIgnoreAfterReset = function(test) {
test.done();
-};
+};
+
+exports.testFailThrowsNoExceptionWhenNotCalled = function(test){
+
+ var mock = nm.mock('test').fail();
+ test.doesNotThrow(function() {
+ // the method was not called so, no exception should be thrown
+ mock.assertThrows();
+ });
+ test.done();
+}

0 comments on commit 1a34453

Please sign in to comment.