I have the following js code
foo() {
return this.bar().then(response => {
return 'I am a cat';
});
}
I want to test the result of this function and have the following jasmine test:
spyOn(MyService, 'bar').and.returnValue($q.when('dummy response'))
MyService.foo().then(result => console.log(result));
$rootScope.$digest();
The code works correctly because it is working in the browser but the test prints 'undefined' instead of 'I am a cat' as I would expect. Does anyone know why or how I make it print 'I am a cat'?