Skip to content

Instantly share code, notes, and snippets.

@clohr
Last active September 8, 2015 15:15
Show Gist options
  • Save clohr/b76400dd2798c9452691 to your computer and use it in GitHub Desktop.
Save clohr/b76400dd2798c9452691 to your computer and use it in GitHub Desktop.
Sinon stub example
'use strict';
var R = require('ramda');
var sinon = require('sinon');
var log = {};
log.warning = R.bind(console.warn, console);
sinon.stub(log, 'warning');
var args = 'this is a test';
log.warning(args);
console.log('called once:', log.warning.calledOnce);
console.log('called with:', log.warning.calledWith(args));
log.warning.restore();
log.warning('restored');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment