Как проверить правильность открытия $modal в Angular/Jasmine?

Есть следующий код:

$scope.removePoint = function(point) {
    $modal.open({
              templateUrl: 'templates/deleting_modal.html',
              controller: 'DeletingPointModalController',
              size: 'sm',
              resolve: {
                points: function() {
                  return $scope.points;
                },
                point: function() {
                  return point;
                }
              }
            });
};

Я хочу проверить это:

describe('HomeController', function() {
  beforeEach(module('app'));

  var $scope;

  beforeEach(inject(function(_$controller_, _$rootScope_){
    $scope = _$rootScope_.$new();
    _$controller_('HomeController', { $scope: $scope });
  }));

});

Но я не понимаю, как я могу проверить, было ли открыто модальное окно. Заранее спасибо!

1 ответ

Вы можете проверить, был ли вызван метод open:

describe('$scope.removePoint', function() {    
    it('should call $modal.open', function() {
        spyOn($modal, 'open');
        $scope.removePoint();
        expect($modal.open).toHaveBeenCalled();
    });
});
Другие вопросы по тегам