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

33 lines
942 B
JavaScript
Raw Normal View History

describe('Directive dialog', () => {
let $element;
let element;
let compile;
let controller;
beforeEach(ngModule('vnCore'));
compile = _element => {
inject(($compile, $rootScope) => {
2020-04-30 05:20:43 +00:00
let $scope = $rootScope.$new();
$scope.myDialog = controller;
element = angular.element(_element);
$compile(element)($scope);
$scope.$digest();
});
};
2020-04-30 05:20:43 +00:00
beforeEach(inject(($rootScope, $compile) => {
$element = $compile('<vn-dialog><tpl-body></tpl-body></vn-dialog>')($rootScope);
controller = $element.controller('vnDialog');
}));
it('should call show() function if dialog is a instance of vnDialog', () => {
let html = `<div vn-dialog="myDialog"></div>`;
2020-02-26 12:22:52 +00:00
jest.spyOn(controller, 'show');
compile(html);
element[0].click();
expect(controller.show).toHaveBeenCalledWith();
});
});