Created
April 25, 2012 12:45
-
-
Save trodrigues/2489500 to your computer and use it in GitHub Desktop.
testing and mocking amd modules with sinon and buster.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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