Skip to content

Instantly share code, notes, and snippets.

@trodrigues
Created April 25, 2012 12:45
Show Gist options
  • Save trodrigues/2489500 to your computer and use it in GitHub Desktop.
Save trodrigues/2489500 to your computer and use it in GitHub Desktop.
testing and mocking amd modules with sinon and buster.js
describe('when initializing a friends module', function(){
before(function(){
var self = this;
require('services/top10', function(top10Service) {
self.getFriendStub = sinon.stub(top10Service, 'getFriendTop10');
self.getTop10Stub = sinon.stub(top10Service, 'get');
});
this.view = new CreateLayoutView({
model: {
bind : function() {}
}
});
this.contribStub = sinon.stub();
this.contribStub.returns(true);
this.view.handleFetchSuccess({
get: this.contribStub,
has: this.contribStub
});
});
it('creates a friend top10 model object', function(){
expect(this.getFriendStub).toBeCalled();
});
it('creates a top10 model object', function(){
expect(this.getTop10Stub).toBeCalled();
});
after(function(){
this.getFriendStub.restore();
this.getTop10Stub.restore();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment