Skip to content

Instantly share code, notes, and snippets.

@simianhacker
Last active December 21, 2015 20:19
Show Gist options
  • Save simianhacker/6360791 to your computer and use it in GitHub Desktop.
Save simianhacker/6360791 to your computer and use it in GitHub Desktop.
var insert = function (data, callback) {
console.log('fail', data);
callback();
}
var update = function (data, callback) {
this.insert(data, callback);
};
module.exports.insert = insert;
module.exports.update = update;
var sinon = require('sinon');
var expect = require('chai').expect;
var m = require('./client');
require('mocha');
describe('example', function () {
var stub;
beforeEach(function () {
stub = sinon.stub(m, 'insert', function (data, callback) {
console.log("override called");
callback();
});
});
afterEach(function () {
m.insert.restore();
});
it('should call insert when m.update is called', function (done) {
m.update({ status: 'ok' }, function () {
sinon.assert.called(stub);
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment