My service is a simple one for Shoes
app.factory('Shoes', function() {
function x() {return 12;}
function y() {return x();}
return {
x: x,
y: y
}
})
I am trying to verify if the method x
gets called when I invoke method y
. My test case is as follows:
describe('Testing a Shoes service', function() {
var service;
beforeEach(module('plunker'));
beforeEach(inject(function(Shoes) {
service = Shoes;
}))
it('.y should call .x', function() {
spyOn(service, 'x');
service.y();
expect(service.x).toHaveBeenCalled();
})
});
However, the tests are not passing. You can view the relevant Plunker here.
How can I effectively test these types of interactions?