2017-10-23 08:47:56 +00:00
|
|
|
describe('Directive dialog', () => {
|
|
|
|
let $scope;
|
|
|
|
let $element;
|
|
|
|
let element;
|
|
|
|
let compile;
|
|
|
|
let $componentController;
|
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('client');
|
|
|
|
});
|
|
|
|
|
|
|
|
compile = _element => {
|
|
|
|
inject(($compile, $rootScope) => {
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$scope.myDialog = controller;
|
|
|
|
element = angular.element(_element);
|
|
|
|
$compile(element)($scope);
|
|
|
|
$scope.$digest();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-01-30 13:48:21 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
|
2017-10-23 08:47:56 +00:00
|
|
|
$componentController = _$componentController_;
|
2018-01-30 13:48:21 +00:00
|
|
|
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
2017-10-23 08:47:56 +00:00
|
|
|
$element = angular.element('<div></div>');
|
|
|
|
controller = $componentController('vnDialog', {$element});
|
|
|
|
}));
|
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|