have angular factory again calls factory- service uses $resource api call. tell me, how can mock , test kind of constructs.
//factory angular.module('myapp') .factory('samplef', function (samples) { return { getdata: function (parm, callback) { var cb = callback || angular.noop; return samples.get(parm, function (res) { return cb(res); }, function (err) { return cb(err); }.bind(this)).$promise; } }; }); // service: samples angular.module('myapp') .factory('samples', function ($resource) { return $resource('http://localhost:8080:/api/sample/:parm', { parm: '@parm', }, {}); }); //api response ` { "firstname": "john", "lastname": "franklin", "companyname": "benton, john b jr", "address": "6649 n blue gum st", "city": "new oakland", "county": "oakland", "statie": "la", "zip": "703333", "phone": "503-321-2227", "phone2": "514-145-427", "email": "john@gmail.com", }
describe('test',function(){ beforeeach(module('myapp')); var samplef,myapp, beforeeach(inject(function(_samplef_,_myapp_){ samplef=_samplef_; myapp=_myapp_; })); it('testing'function(){ //here can call function , expect values }); });
Comments
Post a Comment