diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/frontend/work_items/components/work_item_title_spec.js | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/work_items/components/work_item_title_spec.js')
-rw-r--r-- | spec/frontend/work_items/components/work_item_title_spec.js | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/spec/frontend/work_items/components/work_item_title_spec.js b/spec/frontend/work_items/components/work_item_title_spec.js index 9b1ef2d14e4..19b56362ac0 100644 --- a/spec/frontend/work_items/components/work_item_title_spec.js +++ b/spec/frontend/work_items/components/work_item_title_spec.js @@ -1,4 +1,3 @@ -import { GlLoadingIcon } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; @@ -18,15 +17,13 @@ describe('WorkItemTitle component', () => { const mutationSuccessHandler = jest.fn().mockResolvedValue(updateWorkItemMutationResponse); - const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); const findItemTitle = () => wrapper.findComponent(ItemTitle); - const createComponent = ({ loading = false, mutationHandler = mutationSuccessHandler } = {}) => { + const createComponent = ({ mutationHandler = mutationSuccessHandler } = {}) => { const { id, title, workItemType } = workItemQueryResponse.data.workItem; wrapper = shallowMount(WorkItemTitle, { apolloProvider: createMockApollo([[updateWorkItemMutation, mutationHandler]]), propsData: { - loading, workItemId: id, workItemTitle: title, workItemType: workItemType.name, @@ -38,32 +35,10 @@ describe('WorkItemTitle component', () => { wrapper.destroy(); }); - describe('when loading', () => { - beforeEach(() => { - createComponent({ loading: true }); - }); - - it('renders loading spinner', () => { - expect(findLoadingIcon().exists()).toBe(true); - }); - - it('does not render title', () => { - expect(findItemTitle().exists()).toBe(false); - }); - }); - - describe('when loaded', () => { - beforeEach(() => { - createComponent({ loading: false }); - }); - - it('does not render loading spinner', () => { - expect(findLoadingIcon().exists()).toBe(false); - }); + it('renders title', () => { + createComponent(); - it('renders title', () => { - expect(findItemTitle().props('title')).toBe(workItemQueryResponse.data.workItem.title); - }); + expect(findItemTitle().props('title')).toBe(workItemQueryResponse.data.workItem.title); }); describe('when updating the title', () => { @@ -82,6 +57,15 @@ describe('WorkItemTitle component', () => { }); }); + it('emits updated event', async () => { + createComponent(); + + findItemTitle().vm.$emit('title-changed', 'new title'); + await waitForPromises(); + + expect(wrapper.emitted('updated')).toEqual([[]]); + }); + it('does not call a mutation when the title has not changed', () => { createComponent(); |