I have the following simple service
app.factory('Shoes', function() {
function a() {return 12;}
function b() {return a();}
return {
a: a,
b: b
}
})
I want to test if the method a is being called when I call method b. My test looks like this:
describe('Testing a Shoes service', function() {
var service;
beforeEach(module('plunker'));
beforeEach(inject(function(Shoes) {
service = Shoes;
}))
it('.b should call .a', function() {
spyOn(service, 'a');
service.b();
expect(service.a).toHaveBeenCalled();
})
});
But the tests fail. Relevant plunker is here.
Question is how can I test this kind of interactions?
Aucun commentaire:
Enregistrer un commentaire