Below is an angularJS Factory
angular.module('employer').factory('emp', function($rootScope, $ionicPopup, $state, $window){
var pop = {};
pop.integrate = function(){
return 123;
};
});
Following are Jasmine tests I have tried,
1)
it('integration', function(){
expect(pop.integrate).toEqual(123);
});
This gives me an error - Expected undefined to equal 123.
2)
it('integration', function(){
spyOn(pop, 'integrate');
pop.integrate();
expect(pop.integrate).toHaveBeenCalled();
expect(pop.integrate).toEqual(123);
});
This gives me an error - pop.integrate()
is not a function.
Aucun commentaire:
Enregistrer un commentaire