Observed since 20 Oct, 16:29 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Returns a deep copy of an object with all functions converted to spies
Returns a deep copy of an object with all functions converted to spies.
Install with npm:
npm install 007
// 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);
doubleOhSeven()Takes an object or function as an argument, returns a function or object matching the original, but with mocked out functions.
mockFn.implementationThe 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'
});
MIT
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 16:29 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:04d8499d68938ceec49e772832eff0fb552fcd35b8f21854159616bd9de875eb