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;
|
|
|
|
|
2018-10-18 18:48:21 +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');
|
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
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
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');
|
|
|
|
controller.onDropDownSelect('mariano');
|
2018-09-12 09:06:28 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.field).toBe('mariano');
|
|
|
|
expect(controller.emit).toHaveBeenCalledWith('change', {value: 'mariano'});
|
2018-09-12 09:06:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|