diff options
Diffstat (limited to 'spec/frontend/vue_shared')
-rw-r--r-- | spec/frontend/vue_shared/components/split_button_spec.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/split_button_spec.js b/spec/frontend/vue_shared/components/split_button_spec.js index 91facb7afa4..e09bc073042 100644 --- a/spec/frontend/vue_shared/components/split_button_spec.js +++ b/spec/frontend/vue_shared/components/split_button_spec.js @@ -74,6 +74,7 @@ describe('SplitButton', () => { describe('emitted event', () => { let eventHandler; + let changeEventHandler; beforeEach(() => { createComponent({ actionItems: mockActionItems }); @@ -84,6 +85,11 @@ describe('SplitButton', () => { wrapper.vm.$once(eventName, () => eventHandler()); }; + const addChangeEventHandler = () => { + changeEventHandler = jest.fn(); + wrapper.vm.$once('change', item => changeEventHandler(item)); + }; + it('defaults to first actionItems event', () => { addEventHandler(mockActionItems[0]); @@ -99,5 +105,13 @@ describe('SplitButton', () => { .then(() => { expect(eventHandler).toHaveBeenCalled(); })); + + it('change to selected actionItem emits change event', () => { + addChangeEventHandler(); + + return selectItem(1).then(() => { + expect(changeEventHandler).toHaveBeenCalledWith(mockActionItems[1]); + }); + }); }); }); |