angularjs - how to test service property call -
here temp.js
angular.module('temp', []) .service('tempfactory', function() { this.a = 10; }) .controller('tempctrl', function($scope, tempfactory) { $scope.a = tempfactory.a; });
and here temp.spec.js
describe('temp', function() { var ctrl, scope; beforeeach(function() { module('temp'); inject(function($rootscope, $controller) { scope = $rootscope.new(); ctrl = $controller('tempctrl', {$scope: scope}); }); }); });
i know test service method call necessary use spy. how test service property call(in code $scope.a = tempfactory.a;)? how can find out property of service called?
write spec tests value on scope. no spy needed. write effect of:
it('sets expected value service', function () { expect(scope.a).tobe(10); });
Comments
Post a Comment