I have defined my service as
angular.module('myservice',[]).service('dataService', function () {
var promocodeDetails = {
"havePromocode": false,
"promocode": "",
"OfferHeading": "",
"OfferDescription": "",
"OfferDisclaimer": ""
};
return {
setPromocodeDetails: function (promocode) {
promocodeDetails = promocode;
},
getPromocodeDetails: function () {
return promocodeDetails;
}
};
});
I have written jasmine test for it
describe('Testing dataservice - a service', function(){
beforeEach(function(){
module('myservice');
});
var dataService;
beforeEach(inject(function(_dataService_){
dataService = _dataService_;
}));
it('should set the promocodedetail', function(){
var promocode={
'promocode':'12345'
}
dataService.setPromocodeDetails(promocode);
expect(dataService.getPromocodeDetails().promocode).toEqual('12345');
});
});
When I try to run this test, I get the following error
TypeError: Unable to get property 'setPromocodeDetails' of undefined or null reference
Please suggest as I am stuck with this simple test...
Aucun commentaire:
Enregistrer un commentaire