diff options
Diffstat (limited to 'spec/frontend/vue_mr_widget/components')
4 files changed, 34 insertions, 38 deletions
diff --git a/spec/frontend/vue_mr_widget/components/extensions/index_spec.js b/spec/frontend/vue_mr_widget/components/extensions/index_spec.js new file mode 100644 index 00000000000..8f6fe3cd37a --- /dev/null +++ b/spec/frontend/vue_mr_widget/components/extensions/index_spec.js @@ -0,0 +1,31 @@ +import { registerExtension, extensions } from '~/vue_merge_request_widget/components/extensions'; +import ExtensionBase from '~/vue_merge_request_widget/components/extensions/base.vue'; + +describe('MR widget extension registering', () => { + it('registers a extension', () => { + registerExtension({ + name: 'Test', + props: ['helloWorld'], + computed: { + test() {}, + }, + methods: { + test() {}, + }, + }); + + expect(extensions[0]).toEqual( + expect.objectContaining({ + extends: ExtensionBase, + name: 'Test', + props: ['helloWorld'], + computed: { + test: expect.any(Function), + }, + methods: { + test: expect.any(Function), + }, + }), + ); + }); +}); diff --git a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js index 015f8bbac51..266c906ba60 100644 --- a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js @@ -1,13 +1,7 @@ import Vue from 'vue'; -import Mousetrap from 'mousetrap'; import mountComponent from 'helpers/vue_mount_component_helper'; import headerComponent from '~/vue_merge_request_widget/components/mr_widget_header.vue'; -jest.mock('mousetrap', () => ({ - bind: jest.fn(), - unbind: jest.fn(), -})); - describe('MRWidgetHeader', () => { let vm; let Component; @@ -136,35 +130,6 @@ describe('MRWidgetHeader', () => { it('renders target branch', () => { expect(vm.$el.querySelector('.js-target-branch').textContent.trim()).toEqual('master'); }); - - describe('keyboard shortcuts', () => { - it('binds a keyboard shortcut handler to the "b" key', () => { - expect(Mousetrap.bind).toHaveBeenCalledWith('b', expect.any(Function)); - }); - - it('triggers a click on the "copy to clipboard" button when the handler is executed', () => { - const testClickHandler = jest.fn(); - vm.$refs.copyBranchNameButton.$el.addEventListener('click', testClickHandler); - - // Get a reference to the function that was assigned to the "b" shortcut key. - const shortcutHandler = Mousetrap.bind.mock.calls[0][1]; - - expect(testClickHandler).not.toHaveBeenCalled(); - - // Simulate Mousetrap calling the function. - shortcutHandler(); - - expect(testClickHandler).toHaveBeenCalledTimes(1); - }); - - it('unbinds the keyboard shortcut when the component is destroyed', () => { - expect(Mousetrap.unbind).not.toHaveBeenCalled(); - - vm.$destroy(); - - expect(Mousetrap.unbind).toHaveBeenCalledWith('b'); - }); - }); }); describe('with an open merge request', () => { diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_commit_message_dropdown_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_commit_message_dropdown_spec.js index 5c7e6a87c16..56832f82b05 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_commit_message_dropdown_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_commit_message_dropdown_spec.js @@ -1,5 +1,5 @@ import { shallowMount } from '@vue/test-utils'; -import { GlDeprecatedDropdownItem } from '@gitlab/ui'; +import { GlDropdownItem } from '@gitlab/ui'; import CommitMessageDropdown from '~/vue_merge_request_widget/components/states/commit_message_dropdown.vue'; const commits = [ @@ -39,7 +39,7 @@ describe('Commits message dropdown component', () => { wrapper.destroy(); }); - const findDropdownElements = () => wrapper.findAll(GlDeprecatedDropdownItem); + const findDropdownElements = () => wrapper.findAll(GlDropdownItem); const findFirstDropdownElement = () => findDropdownElements().at(0); it('should have 3 elements in dropdown list', () => { diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js index 6ccf1e1f56b..907906ebe98 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_wip_spec.js @@ -84,7 +84,7 @@ describe('Wip', () => { it('should have correct elements', () => { expect(el.classList.contains('mr-widget-body')).toBeTruthy(); - expect(el.innerText).toContain('This merge request is still a work in progress.'); + expect(el.innerText).toContain('This merge request is still a draft.'); expect(el.querySelector('button').getAttribute('disabled')).toBeTruthy(); expect(el.querySelector('button').innerText).toContain('Merge'); expect(el.querySelector('.js-remove-wip').innerText.replace(/\s\s+/g, ' ')).toContain( |