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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -