Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed issue #12

  fail() throws exception on assertThrows when method was not called
  • Loading branch information...
commit 1a34453ce288c97e9961c907b9702cffb556c1ad 1 parent b901cfc
Arunoda Susiripala authored
Showing with 13 additions and 3 deletions.
  1. +1 −1  lib/nodemock.js
  2. +1 −1  package.json
  3. +11 −1 test/nodemock.js
2  lib/nodemock.js
View
@@ -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"
2  package.json
View
@@ -1,6 +1,6 @@
{
"name": "nodemock",
- "version": "0.2.14",
+ "version": "0.2.15",
"directories": {
"lib": "./lib"
},
12 test/nodemock.js
View
@@ -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();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.