2018-11-08 08:32:41 +00:00
|
|
|
describe('Component vnButtonMenu', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
let controller;
|
2018-09-12 09:06:28 +00:00
|
|
|
let $element;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2018-09-12 09:06:28 +00:00
|
|
|
|
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');
|
2019-06-13 11:08:11 +00:00
|
|
|
controller.valueField = 'name';
|
2018-09-12 09:06:28 +00:00
|
|
|
}));
|
|
|
|
|
2018-10-18 18:48:21 +00:00
|
|
|
afterEach(() => {
|
|
|
|
$element.remove();
|
2018-09-12 09:06:28 +00:00
|
|
|
});
|
|
|
|
|
2019-11-10 12:10:52 +00:00
|
|
|
describe('onButtonClick(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
|
|
|
|
});
|
2019-11-10 12:10:52 +00:00
|
|
|
controller.onButtonClick(event);
|
2018-10-18 18:48:21 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.emit).toHaveBeenCalledWith('open');
|
2018-09-12 09:06:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
2019-06-13 11:08:11 +00:00
|
|
|
controller.onDropDownSelect({name: 'Item name'});
|
2018-09-12 09:06:28 +00:00
|
|
|
|
2019-06-13 11:08:11 +00:00
|
|
|
expect(controller.field).toBe('Item name');
|
|
|
|
expect(controller.emit).toHaveBeenCalledWith('change', {value: 'Item name'});
|
2018-09-12 09:06:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|