ngboilerplate - testing wrapped $http angularjs -


i using angularjs , have test wrapped $http

ang.factory("httpservice", ["$http", "$q", function ($http, $q) { return { get: function (url) {   var result = $q.defer();   $http.get(url).success(function ($data) {     result.resolve($data);   }).error(function ($data) {     result.reject($data);   });   return result.promise; }  }; }]); 

and think test should

beforeeach(module('ngboilerplate.employee', function ($provide) {   httpservice = jasmine.createspyobj("httpservice", ["get", "post"]);    $provide.value("httpservice", httpservice); }));    beforeeach(inject(function (_$controller_, _$rootscope_, _httpservice_) {   $scope = _$rootscope_.$new();   httpservice = _httpservice_;   $controller = _$controller_('employeectrl', {$scope: $scope, httpservice: httpservice}); })); 

ps: using ngboilerplate. thanks


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -