dimanche 30 juillet 2017

Unit test using jasmine controller calls $resource in service

I am new to Jasmine unit testing and i am using angular controller and service where the controller calls service to return $resource get.How to write a function in jasmine for the below controller and service code?

controller code

(function () {

angular

     .module('TestModule')

     .controller('TestController', function (TestService) {

         var vm = this;

         TestService.get().$promise.then(function (data) {

             vm.bookmarks = data;
         });




     });

})();

service code

(function () {

angular

       .module('TestModule')

        .service('TestService', function ($resource) {


            return $resource('http://localhost:60334/api/event/123', {});

        })

})();

Aucun commentaire:

Enregistrer un commentaire