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
Post a Comment