2017-10-23 08:47:56 +00:00
|
|
|
describe('Directive dialog', () => {
|
|
|
|
let $scope;
|
|
|
|
let $element;
|
|
|
|
let element;
|
|
|
|
let compile;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2017-10-23 08:47:56 +00:00
|
|
|
|
|
|
|
compile = _element => {
|
|
|
|
inject(($compile, $rootScope) => {
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$scope.myDialog = controller;
|
|
|
|
element = angular.element(_element);
|
|
|
|
$compile(element)($scope);
|
|
|
|
$scope.$digest();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-10-28 16:31:33 +00:00
|
|
|
beforeEach(angular.mock.inject(($rootScope, $compile) => {
|
|
|
|
$element = $compile('<vn-dialog><tpl-body></tpl-body></vn-dialog>')($rootScope);
|
|
|
|
controller = $element.controller('vnDialog');
|
2017-10-23 08:47:56 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
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');
|
2017-10-23 08:47:56 +00:00
|
|
|
compile(html);
|
|
|
|
element[0].click();
|
|
|
|
|
|
|
|
expect(controller.show).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|