Catalog npm
PACKAGE EXPLORERView in registry

007

npm

Returns a deep copy of an object with all functions converted to spies

mockspytesttesting
Versions collected3
Direct dependencies2From release 0.0.2
Last observed20 Oct, 16:29 UTC

README

Version 0.0.2 documentation

007

Build Status

Returns a deep copy of an object with all functions converted to spies.

Install

Install with npm:

npm install 007

Example

// we want to test github
var github = require('github');
var doubleOhSeven = require('007');
var mockGithub = doubleOhSeven(github);

mockGithub.pullRequests.getCommits.returns = function () {
  return {
    foo: 'beep'
  };
};

assert(mockGithub.pullRequests.getCommits('lalala').foo === 'beep');
assert(mockGithub.pullRequests.getCommits.callCount === 1);

API

doubleOhSeven()

Takes an object or function as an argument, returns a function or object matching the original, but with mocked out functions.

mockFn.implementation

The implementation of the mock function. Set with =:

Ex:

mockFn.implementation = function (val, cb) {
  return cb(val + 1);
};

The following functions are helpers for implementation; using them will override mockFn.implementation.

mockFn.returns()

The return value of the mock.

Ex:

mockFn.returns('foo');
mockFn(function (arg) {
  console.log(arg); // outputs 'foo'
});

mockFn.callbackArgs()

The callback args to be invoked by the mock.

Ex:

mockFn.callbackArgs(['foo']);
mockFn(function (arg) {
  console.log(arg); // outputs 'foo'
});

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 3

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.2Registry latest29 Jul 20132
0.0.126 Jul 20132
0.0.026 Jul 20130

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
btford/007

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 16:29 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:04d8499d68938ceec49e772832eff0fb552fcd35b8f21854159616bd9de875eb