Skip to content

Instantly share code, notes, and snippets.

@ansmith
Last active August 29, 2015 13:56
Show Gist options
  • Save ansmith/8959855 to your computer and use it in GitHub Desktop.
Save ansmith/8959855 to your computer and use it in GitHub Desktop.
describe("MyService", function() {
'use strict';
var service;
beforeEach(module('myApp'));
beforeEach(inject(function($templateCache) {
//Whatever the default route is, needs to be cached so $httpBackend doesn't see other requests
$templateCache.put('views/default.html', __html__['src/main/webapp/views/default.html']);
}));
it('makes a request', inject(function(MyService, $httpBackend) {
spyOn(MyService, 'getState').andReturn({
method: 'GET',
url: '/services/MyService',
data: {
key1: 'value1'
}
});
$httpBackend.expectGET('/services/MyService?key1=value1').respond();
MyService.save('key1');
$httpBackend.flush();
}));
});
@grgur
Copy link

grgur commented Feb 20, 2014

'use strict' should belong to a function

@ansmith
Copy link
Author

ansmith commented Mar 10, 2014

Haha... yea, I cut and pasted that from somewhere. Should've thought about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment