Skip to content

Instantly share code, notes, and snippets.

@jeffsheets
Created September 1, 2015 15:17
Show Gist options
  • Save jeffsheets/11b053fda68be990900e to your computer and use it in GitHub Desktop.
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
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