Created
September 1, 2015 15:17
-
-
Save jeffsheets/11b053fda68be990900e to your computer and use it in GitHub Desktop.
Simple Karma spec using Sinon to mock a backend service for AngularJS testing
This file contains hidden or 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
var someService; | |
beforeEach(inject(function (_someService_) { | |
someService = sinon.mock(_someService_); | |
})); | |
afterEach(function () { | |
entityServiceFactory.verify(); | |
}); | |
describe('someOtherService method', function () { | |
it('should call someService', function () { | |
someService.doCoolThings.withArgs('model', {day: "01/01/2010"}).returns([ | |
{name: "foo"}, | |
{name: "bar"} | |
]); | |
var result = someOtherService.doReallyCoolThings({day: "01/01/2010"}); | |
expect(result[0].name).to.equal("foo"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment