salix/front/core/components/button-menu/button-menu.spec.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-11-08 08:32:41 +00:00
describe('Component vnButtonMenu', () => {
2018-11-06 13:27:16 +00:00
let controller;
let $element;
2018-10-18 18:48:21 +00:00
beforeEach(ngModule('vnCore'));
2018-10-18 18:48:21 +00:00
beforeEach(inject(($compile, $rootScope) => {
$element = $compile(`<vn-icon-menu></vn-icon-menu>`)($rootScope);
2018-11-06 13:27:16 +00:00
controller = $element.controller('vnIconMenu');
}));
2018-10-18 18:48:21 +00:00
afterEach(() => {
$element.remove();
});
describe('onClick(event)', () => {
2018-10-18 18:48:21 +00:00
it(`should emit the open event`, () => {
2018-11-06 13:27:16 +00:00
spyOn(controller, 'emit');
2018-10-18 18:48:21 +00:00
let event = new MouseEvent('click', {
2018-11-06 13:27:16 +00:00
view: controller.element.window,
2018-10-18 18:48:21 +00:00
bubbles: true,
cancelable: true
});
2018-11-06 13:27:16 +00:00
controller.onClick(event);
2018-10-18 18:48:21 +00:00
2018-11-06 13:27:16 +00:00
expect(controller.emit).toHaveBeenCalledWith('open');
});
});
describe('onDropDownSelect(value)', () => {
2018-10-18 18:48:21 +00:00
it(`should set field to the given value and emit the change event`, () => {
2018-11-06 13:27:16 +00:00
spyOn(controller, 'emit');
controller.onDropDownSelect('mariano');
2018-11-06 13:27:16 +00:00
expect(controller.field).toBe('mariano');
expect(controller.emit).toHaveBeenCalledWith('change', {value: 'mariano'});
});
});
});