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

nodemock

Package Overview
Dependencies
Maintainers
2
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.3.2 to 0.3.3

14

lib/nodemock.js

@@ -186,2 +186,3 @@ /**

var messages = [],
mock = this,
methodName,

@@ -195,3 +196,3 @@ method,

methodName = self.context ? self.context + "#" + method : method;
messages.push("Method " + methodName + getParamString(entry.args) + " was not called");
messages.push("Method " + mock._name + methodName + getParamString(entry.args) + " was not called");
}

@@ -364,5 +365,14 @@ });

if(typeof(exports) != "undefined") {
var currentName = '';
exports.named = function(mockName) {
currentName = mockName;
return exports;
};
exports.mock = function(methodName) {
return new NodeMock(methodName);
var mock = new NodeMock(methodName);
mock._name = currentName? currentName + '.' : '';
currentName = '';
return mock;
};

@@ -369,0 +379,0 @@

2

package.json
{
"name": "nodemock",
"version": "0.3.2",
"version": "0.3.3",
"directories": {

@@ -5,0 +5,0 @@ "test": "test"

@@ -48,2 +48,13 @@ A simple Yet Powerful Mocking Framework for NodeJs

### Name a mock for clarity
var mocks = [
nodemock.named('mock1').mock('foo').takes(1),
nodemock.named('mock2').mock('foo').takes(1)
],
i;
for(i = 0; i < mocks.length; i += 1) {
mocks[i].assert(); // Prints that «mockName».foo(1) was not called.
}
### Creating a mock function with taking arguments and return value

@@ -50,0 +61,0 @@ var mocked = nodemock.mock("foo").takes(10, [10, 20, 30]).returns(98);

@@ -30,2 +30,15 @@ /*

exports.mocksHaveNames = function(test) {
var mockName = 'myFabulousMock',
mock = nm.named(mockName).mock('foo').takes(1);
try {
mock.assertThrows();
} catch(e) {
test.ok(e.message.indexOf(mockName) > -1);
}
test.expect(1);
test.done();
};
exports.testArgumentSimple = function(test) {

@@ -251,3 +264,3 @@

var mock = nm.mock("foo").takes(10, 20).returns(30);
var mock = nm.named('mocky').mock("foo").takes(10, 20).returns(30);
mock.mock("foo").takes(10, 30).returns(40);

@@ -262,3 +275,3 @@

var mock = nm.mock("foo").takes(10, 20).returns(30);
var mock = nm.named('mockier').mock("foo").takes(10, 20).returns(30);
mock.mock("bar").takes(10, 30).returns(40);

@@ -265,0 +278,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