describe('Component vnButtonMenu', () => { let controller; let $element; beforeEach(ngModule('vnCore')); beforeEach(inject(($compile, $rootScope) => { $element = $compile(``)($rootScope); controller = $element.controller('vnIconMenu'); controller.valueField = 'name'; })); afterEach(() => { $element.remove(); }); describe('onClick(event)', () => { it(`should emit the open event`, () => { spyOn(controller, 'emit'); let event = new MouseEvent('click', { view: controller.element.window, bubbles: true, cancelable: true }); controller.onClick(event); expect(controller.emit).toHaveBeenCalledWith('open'); }); }); describe('onDropDownSelect(value)', () => { it(`should set field to the given value and emit the change event`, () => { spyOn(controller, 'emit'); controller.onDropDownSelect({name: 'Item name'}); expect(controller.field).toBe('Item name'); expect(controller.emit).toHaveBeenCalledWith('change', {value: 'Item name'}); }); }); });