I would like to Jasmine test that Welcome.go has been called. Welcome is an angular service.
angular.module('welcome',[])
.run(function(Welcome) {
Welcome.go();
});
This is my test so far:
describe('module: welcome', function () {
beforeEach(module('welcome'));
var Welcome;
beforeEach(inject(function(_Welcome_) {
Welcome = _Welcome_;
spyOn(Welcome, 'go');
}));
it('should call Welcome.go', function() {
expect(Welcome.go).toHaveBeenCalled();
});
});
Note:
- welcome (lowercase w) is the module
- Welcome (uppercase W) is the service
Welcome.go()
does, but you might consider calling that from one of your app's top level controllers, which you can test as shown above. – Eleanoraeleanore