karma runner - Jasmine: Function with transformResponse/resolve -
i have function in controller:
function get(request) { return userservice.get({ id: request.id, transformresponse: function(data) { return angular.fromjson(data); } }); };
and test this:
var $scope; var controller; var userservice; beforeeach(function() { angular.mock.module(function($provide) { userservice = jasmine.createspyobj('userservice', ['get']); $provide.value('userservice', userservice); }); }); beforeeach(inject(function($rootscope, $controller, userservice) { $scope = $rootscope.$new(); controller = $controller('...' { $scope: $scope, userservice: userservice }); $scope.$digest(); })); it('should call user service function when getting user', function() { var request = { id: 5 }; controller.get(request); expect(userservice.get).tohavebeencalledwith(request); });
test passed, karma coverage display function transformresponse not covered test. how must correctly mock function? thanks!
Comments
Post a Comment