angularjs - How to do unit testing using jasmine on that factory? -
i try make unit test on code consists of factory take behavior name , contracts http request in closure ?
var app = angular.module("behaviour",[]); var behaviour = app.factory('behaviours',['http',function(http){ var behavioursjson = $http.get('data.json'); return { getbehaviour : function(behaviourname) { if (behavioursjson[behaviourname]) { var behaviour = behavioursjson[behaviourname]; return function (behaviourdata, callback) { var keys = object.allkeys(behaviourdata); var headers = {}; var data = {}; var url = behaviour.path; // process fill headers , data objects $http({ method: behaviour.method, url: url, data: data, headers: headers }).then(function successcallback(response) { callback(response,null); },function errorcallback(error) { callback(null,error); }); } }; return null; } } }]);
note: using jasmine
Comments
Post a Comment