mardi 2 février 2016

Access to the local variable while directive unit testing in AngularJS

I need to test some directive and for that to get one of its local variables to check its value. The directive itself looks this:

angular.module('app').directive('favoritesList', function () {
  return {
    restrict: 'E',
    replace: true,
    templateUrl: 'templates/directives/favoritesListDirective.html',
    controller: function ($scope, $rootScope, $rootElement, $filter, ContactService, ContactFollowerService, Restangular) {

      var listLimit = 100, // in order to prevent favoritesList *overflow*
          followedFilter = {filters: {followed: true}, page_size:listLimit};

      // get Favorites List
      ContactService.provider.getList( followedFilter ) //
        .then(function(result){
          $scope.favorites=result;
        }, function(message){
          console.warn('Cannot get a Favorites List',message);
        });

      ....


    }
  };
});

So, how can I get access to the followedFilter variable in the describe/it blocks?

Aucun commentaire:

Enregistrer un commentaire