47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
|
fdescribe('Directive http-click', () => {
|
||
|
let $scope;
|
||
|
let $element;
|
||
|
let element;
|
||
|
let compile;
|
||
|
let controller;
|
||
|
|
||
|
beforeEach(ngModule('vnCore'));
|
||
|
|
||
|
compile = (_element, _childElement) => {
|
||
|
inject(($componentController, $compile, $rootScope) => {
|
||
|
$scope = $rootScope.$new();
|
||
|
element = angular.element(_element);
|
||
|
$compile(element)($scope);
|
||
|
|
||
|
/* controller = element.controller('vnHttpClick');
|
||
|
controller.myEvent = () => {
|
||
|
return Promise.resolve('hola');
|
||
|
}; */
|
||
|
|
||
|
controller = $componentController('vnHttpClick', {$element: element, $scope: $scope});
|
||
|
controller.myEvent = () => {
|
||
|
return Promise.resolve('hola');
|
||
|
};
|
||
|
|
||
|
$scope.$digest();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
beforeEach(angular.mock.inject(($rootScope, $compile) => {
|
||
|
$element = $compile('<vn-http-click></vn-http-click>')($rootScope);
|
||
|
controller = $element.controller('vnHttpClick');
|
||
|
}));
|
||
|
|
||
|
it('should call focus function on the element', () => {
|
||
|
// jest.spyOn(controller, 'myEvent').mockReturnValue(Promise.resolve());
|
||
|
|
||
|
let html = `<input vn-http-click="$ctrl.myEvent()"/>`;
|
||
|
compile(html);
|
||
|
|
||
|
element[0].$ctrl = {};
|
||
|
element[0].click();
|
||
|
|
||
|
// expect($element[0].focus).toHaveBeenCalledWith();
|
||
|
});
|
||
|
});
|