As someone who is relatively new to Jasmine Testing and the Angular framework, I find myself in a unique situation. I am currently struggling with referencing my service functions in my Jasmine tests.
Here is a snippet of my Angular Service Initialization:
var service = {
checkIfCurrentIsObject: checkIfCurrentIsObject,
removeFromCurrentObject: removeFromCurrentObject;
}
function checkIfCurrentIsObject() {
return getCurrent().isObject();
}
function removeFromCurrentIsObject() {
checkIfCurrentIsObject();
return specialFunction();
}
Now, in my Karma Test:
describe('when current object is property', function() {
it('verify the requote function is called', function() {
spyOn(Service, 'checkIfCurrentIsObject').and.returnValue(true);
spyOn(Service, 'removeFromCurrentIsObject').and.callThrough();
spyOn(Service, 'specialFunction');
expect(Service, 'specialFunction').toHaveBeenCalled();
});
The issue I am currently facing is that my spyOn method does not detect my checkIfCurrentIsObject function unless I specifically reference it as this.checkIfCurrentIsObject
in my removeFromCurrentIsObject
function. Can anyone shed light on why this might be happening?