Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodemock

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemock - npm Package Compare versions

Comparing version 0.2.1beta to 0.2.2beta

14

lib/nodemock.js

@@ -43,15 +43,15 @@ /**

if(shouldFail[method]) {
throw "You should not call anymethod on this object";
throw new Error("You should not call anymethod on this object");
} else if(!this[method]) {
throw "Mock function '" + method + "()' is not defined";
throw new Error("Mock function '" + method + "()' is not defined");
} else if((args[method].length != arguments.length)) {
throw "Number of Arguments passed(" + arguments.length +
throw new Error("Number of Arguments passed(" + arguments.length +
") is not tally with expected(" + args[method].length +
") in '" + methodName + "()'";
") in '" + method + "()'");
} else if(!deepObjectCheck(args[method], arguments)) {
//check for argument content
throw "Arguments content passed is not tally with expected";
throw new Error("Arguments content passed is not tally with expected");
}

@@ -65,3 +65,3 @@

} else {
throw "Expected callback is not defined as callback";
throw new Error("Expected callback is not defined as callback");
}

@@ -89,3 +89,3 @@ }

} else {
throw "First arg of the calls() should be the index of the callback";
throw new Error("First arg of the calls() should be the index of the callback");
}

@@ -92,0 +92,0 @@

{
"name": "nodemock",
"version": "0.2.1beta",
"version": "0.2.2beta",
"directories": {

@@ -23,2 +23,2 @@ "lib": "./lib"

}
}
}

@@ -18,2 +18,3 @@ Node Mock - Simple Yet Powerful Mocking Framework for NodeJs

* Method chaining allows creating mocks super easy
* Fail support added when calling method that should not be called

@@ -69,2 +70,13 @@ Testing

### Fails when calls any method in the mock object
var mocked = nodemock.fail();
mocked.foo(); //thorws an exception
mocked.bar(); //throws an exception
### Fails when calls some particular method in the mock object
var mocked = nodemock.mock("foo").fail();
mocked.mock("bar").takes(10);
mocked.foo(); //thorws an exception
mocked.bar(10); //works perfectly
API Documentation

@@ -94,2 +106,6 @@ -----------------

mocked.fail()
If calls at very begining afterword any call on the mocked objects will fail
Otherwise current mock method will fails someone called that.
License

@@ -96,0 +112,0 @@ -------

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc