Я пытаюсь unit test простую директиву, но переменная в области всегда undefined.
Директива Код Src:
.directive('ratingButton', ['$rootScope',
function($rootScope) {
      return {
          restrict: "E",
          replace: true,
          template: '<button type="button" class="btn btn-circle" ng-class="getRatingClass()"></button>',
          scope: {
              buttonRating: "="
          },
          link: function(scope, elem, attr) {
              scope.getRatingClass = function() {
                  if (!scope.buttonRating)
                      return '';
                  else if (scope.buttonRating.toUpperCase() === 'GREEN')
                      return 'btn-success';
                  else if (scope.buttonRating.toUpperCase() === 'YELLOW')
                      return 'btn-warning warning-text';
                  else if (scope.buttonRating.toUpperCase() === 'RED')
                      return 'btn-danger';
                  else if (scope.buttonRating.toUpperCase() === 'BLUE')
                      return 'btn-info';
              }
          }
      };
  }])
Тест:
describe('Form Directive: ratingButton', function() {
    // load the controller module
    beforeEach(module('dashboardApp'));
    var scope,
        element;
    // Initialize the controller and a mock scope
    beforeEach(inject(function($compile, $rootScope) {
        scope = $rootScope.$new();
        //set our view html.
        element = angular.element('<rating-button button-rating="green"></rating-button>');
        $compile(element)(scope);
        scope.$digest();
    }));
    it('should return appropriate class based on rating', function() {
        //console.log(element.isolateScope());
        expect(element.isolateScope().buttonRating).toBe('green');
        expect(element.isolateScope().getRatingClass()).toBe('btn-success');
    });
});
Я использовал аналогичный код в другой директиве unit test, я передал значения через атрибуты элементов, и он работал, как ожидалось. Для этого теста buttonRating всегда undefined не уверен, куда идти отсюда (я довольно новичок в Jasmine/Karma)
Любая помощь будет замечательной!
