Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created October 22, 2013 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ynonp/7101081 to your computer and use it in GitHub Desktop.
Save ynonp/7101081 to your computer and use it in GitHub Desktop.
var assert = chai.assert;
describe('Sinon', function() {
describe('spies', function() {
it('should keep count', function() {
// fill code here
spy();
spy();
spy();
assert.equal( spy.callCount, 3 );
});
it('should spy on existing code', function() {
var arr = [10, 20, 30];
// fill code here
arr.push( 40 );
assert.isTrue( spy.calledOnce );
});
it('should stop spying when done', function() {
var arr = [10, 20, 30];
// fill code here
arr.push( 40 );
assert.isTrue( spy.calledOnce );
// fill code here
arr.push(50);
assert.isTrue( spy.calledOnce );
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment