diff options
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/vue_merge_request_widget/components/action_buttons_spec.js (renamed from spec/frontend/vue_merge_request_widget/components/action_buttons.js) | 26 | ||||
-rw-r--r-- | spec/frontend/vue_merge_request_widget/components/states/mr_widget_merged_spec.js | 6 |
2 files changed, 25 insertions, 7 deletions
diff --git a/spec/frontend/vue_merge_request_widget/components/action_buttons.js b/spec/frontend/vue_merge_request_widget/components/action_buttons_spec.js index 7334f061dc9..02e23b81413 100644 --- a/spec/frontend/vue_merge_request_widget/components/action_buttons.js +++ b/spec/frontend/vue_merge_request_widget/components/action_buttons_spec.js @@ -1,4 +1,4 @@ -import { GlButton, GlDropdownItem } from '@gitlab/ui'; +import { GlButton, GlDisclosureDropdown } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import Actions from '~/vue_merge_request_widget/components/action_buttons.vue'; @@ -6,7 +6,7 @@ let wrapper; function factory(propsData = {}) { wrapper = shallowMount(Actions, { - propsData: { ...propsData, widget: 'test' }, + propsData, }); } @@ -33,11 +33,29 @@ describe('MR widget extension actions', () => { }); it('renders tertiary actions in dropdown', () => { + const action = { text: 'hello world', href: 'https://gitlab.com', target: '_blank' }; factory({ - tertiaryButtons: [{ text: 'hello world', href: 'https://gitlab.com', target: '_blank' }], + tertiaryButtons: [action, action], }); - expect(wrapper.findAllComponents(GlDropdownItem)).toHaveLength(1); + const component = wrapper.findComponent(GlDisclosureDropdown); + expect(component.exists()).toBe(true); + expect(component.props('items')).toMatchObject([ + { + text: action.text, + href: action.href, + extraAttrs: { + target: action.target, + }, + }, + { + text: action.text, + href: action.href, + extraAttrs: { + target: action.target, + }, + }, + ]); }); }); }); diff --git a/spec/frontend/vue_merge_request_widget/components/states/mr_widget_merged_spec.js b/spec/frontend/vue_merge_request_widget/components/states/mr_widget_merged_spec.js index e44e2834a0e..5efb1dcce42 100644 --- a/spec/frontend/vue_merge_request_widget/components/states/mr_widget_merged_spec.js +++ b/spec/frontend/vue_merge_request_widget/components/states/mr_widget_merged_spec.js @@ -1,4 +1,4 @@ -import { getByRole } from '@testing-library/dom'; +import { getAllByRole } from '@testing-library/dom'; import { nextTick } from 'vue'; import { mount } from '@vue/test-utils'; import waitForPromises from 'helpers/wait_for_promises'; @@ -132,7 +132,7 @@ describe('MRWidgetMerged', () => { createComponent(); const eventHubSpy = jest.spyOn(modalEventHub, '$emit'); - getByRole(wrapper.element, 'button', { name: /Revert/i }).click(); + getAllByRole(wrapper.element, 'button', { name: /Revert/i })[0].click(); expect(eventHubSpy).toHaveBeenCalledWith(OPEN_REVERT_MODAL); }); @@ -141,7 +141,7 @@ describe('MRWidgetMerged', () => { createComponent(); const eventHubSpy = jest.spyOn(modalEventHub, '$emit'); - getByRole(wrapper.element, 'button', { name: /Cherry-pick/i }).click(); + getAllByRole(wrapper.element, 'button', { name: /Cherry-pick/i })[0].click(); expect(eventHubSpy).toHaveBeenCalledWith(OPEN_CHERRY_PICK_MODAL); }); |