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.0beta to 0.2.1beta

19

lib/nodemock.js

@@ -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 {};
};
}

13

package.json
{
"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();
};
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