salix/front/core/directives/specs/dialog.spec.js

36 lines
1.0 KiB
JavaScript

describe('Directive dialog', () => {
let $scope;
let $element;
let element;
let compile;
let controller;
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
compile = _element => {
inject(($compile, $rootScope) => {
$scope = $rootScope.$new();
$scope.myDialog = controller;
element = angular.element(_element);
$compile(element)($scope);
$scope.$digest();
});
};
beforeEach(angular.mock.inject($componentController => {
$element = angular.element('<div></div>');
controller = $componentController('vnDialog', {$element: $element, $transclude: null});
}));
it('should call show() function if dialog is a instance of vnDialog', () => {
let html = `<div vn-dialog="myDialog"></div>`;
spyOn(controller, 'show');
compile(html);
element[0].click();
expect(controller.show).toHaveBeenCalledWith();
});
});