My service is
var testappserviceone = angular.module('testappserviceonemodule',[])
testappserviceone.factory('testappServiceone',[function(){
return function (x,y) {
function addobj (x,y){
return x+y;
}
return{
add:addobj
}
}
}]);
My test suite is
describe('testappserviceone add method functionality', function(){
beforeEach(function () {
spyOn(testappServiceone(10,15),'add').and.callThrough();
});
it('testappServiceone add method functionality', function() {
testappServiceone(10,15).add();
expect(testappServiceone(10,15).add).toHaveBeenCalled();
});
});
The Exception I am getting is
Expected a spy, but got Function.
I think spy() is not creating a spy . Please help me in understanding and solving this problem.
Aucun commentaire:
Enregistrer un commentaire