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

simple-mock

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-mock - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

index.js

@@ -5,2 +5,3 @@ (function (global, module) { // Browser compatibility

var mocks = [];
var totalCalls = 0;

@@ -78,2 +79,3 @@ /**

var call = {
k: totalCalls++, // Keep count of calls to record the absolute order of calls
args: Array.prototype.slice.call(arguments, 0)

@@ -80,0 +82,0 @@ };

3

package.json
{
"name": "simple-mock",
"version": "0.2.4",
"version": "0.2.5",
"description": "Super simple mocks, stubs, and spies with 1-step sandbox restore",

@@ -15,3 +15,2 @@ "main": "index.js",

"test",
"sinon",
"simplemock",

@@ -18,0 +17,0 @@ "simple",

@@ -119,2 +119,3 @@ # simple-mock ![Project status](https://secure.travis-ci.org/jupiter/node-simple-mock.png?branch=master)

- **call.threw** the error thrown by the wrapped function
- **call.k** autoincrementing number, can be compared to evaluate call order

@@ -129,3 +130,3 @@ ### spy.lastCall

Configures this stub to call back with the arguments passed. It will use the last argument as callback, or argument at `argumentIndex`. Subsequent calls of this on the same stub (chainable) will queue up different behaviours for each subsequent call of the stub.
Configures this stub to call back with the arguments passed. It will use either the last argument as callback, or the argument at `argumentIndex`. Subsequent calls of this on the same stub (chainable) will queue up different behaviours for each subsequent call of the stub.

@@ -154,2 +155,2 @@ ### stub.returnWith(val)

The most complete, framework-agnostic mocking library is [sinon.js](http://sinonjs.org/). It also has pages of documentation and lots of sugar-coating that we generally don't need. Just because it is there doesn't mean you need to use it. Keep it simple!
The most complete, framework-agnostic mocking library is [sinon.js](http://sinonjs.org/). It also has pages of documentation and lots of sugar-coating that we generally don't need. Just because it is there doesn't mean you need it. Keep it simple!

@@ -162,2 +162,20 @@ 'use strict';

});
describe('calls of multiple spies', function() {
it('can be compared to determine the order they were called in', function() {
var spy1 = simple.spy(function(){});
var spy2 = simple.spy(function(){});
var spy3 = simple.spy(function(){});
spy1();
spy3();
spy2();
spy1();
assert(spy1.lastCall.k > spy2.lastCall.k);
assert(spy1.lastCall.k > spy3.lastCall.k);
assert(spy2.lastCall.k > spy3.lastCall.k);
assert(spy3.lastCall.k > spy1.calls[0].k);
});
});
});

@@ -164,0 +182,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