salix/front/core/components/chip/index.spec.js

32 lines
913 B
JavaScript
Raw Permalink Normal View History

2018-09-07 10:20:57 +00:00
import './index.js';
import template from './index.html';
describe('Component vnChip', () => {
let $element;
let $scope;
let controller;
beforeEach(ngModule('vnCore'));
2018-09-07 10:20:57 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, $rootScope) => {
2018-09-07 10:20:57 +00:00
$scope = $rootScope.$new();
$element = angular.element(`<div>${template}</div>`);
controller = $componentController('vnChip', {$element, $scope, $transclude: () => {}});
2018-09-07 10:20:57 +00:00
}));
2019-10-18 19:36:30 +00:00
describe('onRemove()', () => {
it(`should emit remove event`, () => {
controller.emit = () => {};
2020-02-26 12:22:52 +00:00
jest.spyOn(controller, 'emit');
2018-09-07 10:20:57 +00:00
2021-06-18 06:03:55 +00:00
const $event = new Event('click');
const target = document.createElement('div');
target.dispatchEvent($event);
controller.onRemove($event);
expect(controller.emit).toHaveBeenCalledWith('remove', {$event});
2018-09-07 10:20:57 +00:00
});
});
});