i am trying to unit test the below function :
Service.test = function(id) {
return this.getDetails(id).then(function (details){
return "name";
});
};
So far i have tried it by myself and done the following thing:
describe(
'TempServ',
function() {
var TempSer, $httpBackend, $q, CapabilityService;
beforeEach(inject(function(_TempServ_, _$httpBackend_, _$q_,
_CapabilityService_) {
TempServ = _TempServ_;
$q = _$q_;
$httpBackend = _$httpBackend_;
CapabilityService = _CapabilityService_;
}));
it(" should be in Pending state",function() {
spyOn(TemplateService, 'getDetails').and.callThrough();
console.log(TemplateService.test());
});
});
I want something, that can mock the getDetails and i can return what i want instead what really would be returned and test function to work by itself fully . Only the getDetails to be mocked!