diff options
Diffstat (limited to 'spec/frontend/error_tracking/components/error_tracking_list_spec.js')
-rw-r--r-- | spec/frontend/error_tracking/components/error_tracking_list_spec.js | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/spec/frontend/error_tracking/components/error_tracking_list_spec.js b/spec/frontend/error_tracking/components/error_tracking_list_spec.js index 74d5731bbea..59671c175e7 100644 --- a/spec/frontend/error_tracking/components/error_tracking_list_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_list_spec.js @@ -1,5 +1,6 @@ import { GlEmptyState, GlLoadingIcon, GlFormInput, GlPagination, GlDropdown } from '@gitlab/ui'; -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import stubChildren from 'helpers/stub_children'; import ErrorTrackingActions from '~/error_tracking/components/error_tracking_actions.vue'; @@ -8,8 +9,7 @@ import { trackErrorListViewsOptions, trackErrorStatusUpdateOptions } from '~/err import Tracking from '~/tracking'; import errorsList from './list_mock.json'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ErrorTrackingList', () => { let store; @@ -32,7 +32,6 @@ describe('ErrorTrackingList', () => { stubs = {}, } = {}) { wrapper = mount(ErrorTrackingList, { - localVue, store, propsData: { indexPath: '/path', @@ -317,15 +316,14 @@ describe('ErrorTrackingList', () => { expect(findRecentSearchesDropdown().text()).toContain("You don't have any recent searches"); }); - it('shows items', () => { + it('shows items', async () => { store.state.list.recentSearches = ['great', 'search']; - return wrapper.vm.$nextTick().then(() => { - const dropdownItems = wrapper.findAll('.filtered-search-box li'); - expect(dropdownItems.length).toBe(3); - expect(dropdownItems.at(0).text()).toBe('great'); - expect(dropdownItems.at(1).text()).toBe('search'); - }); + await nextTick(); + const dropdownItems = wrapper.findAll('.filtered-search-box li'); + expect(dropdownItems.length).toBe(3); + expect(dropdownItems.at(0).text()).toBe('great'); + expect(dropdownItems.at(1).text()).toBe('search'); }); describe('clear', () => { @@ -337,23 +335,21 @@ describe('ErrorTrackingList', () => { expect(clearRecentButton().exists()).toBe(false); }); - it('is visible when list has items', () => { + it('is visible when list has items', async () => { store.state.list.recentSearches = ['some', 'searches']; - return wrapper.vm.$nextTick().then(() => { - expect(clearRecentButton().exists()).toBe(true); - expect(clearRecentButton().text()).toBe('Clear recent searches'); - }); + await nextTick(); + expect(clearRecentButton().exists()).toBe(true); + expect(clearRecentButton().text()).toBe('Clear recent searches'); }); - it('clears items on click', () => { + it('clears items on click', async () => { store.state.list.recentSearches = ['some', 'searches']; - return wrapper.vm.$nextTick().then(() => { - clearRecentButton().vm.$emit('click'); + await nextTick(); + clearRecentButton().vm.$emit('click'); - expect(actions.clearRecentSearches).toHaveBeenCalledTimes(1); - }); + expect(actions.clearRecentSearches).toHaveBeenCalledTimes(1); }); }); }); @@ -388,7 +384,7 @@ describe('ErrorTrackingList', () => { describe('and the user is not on the first page', () => { describe('and the previous button is clicked', () => { - beforeEach(() => { + beforeEach(async () => { store.state.list.loading = false; mountComponent({ stubs: { @@ -399,7 +395,7 @@ describe('ErrorTrackingList', () => { // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // eslint-disable-next-line no-restricted-syntax wrapper.setData({ pageValue: 2 }); - return wrapper.vm.$nextTick(); + await nextTick(); }); it('fetches the previous page of results', () => { @@ -451,7 +447,7 @@ describe('ErrorTrackingList', () => { expect(Tracking.event).toHaveBeenCalledWith(category, action); }); - it('should track status updates', () => { + it('should track status updates', async () => { Tracking.event.mockClear(); const status = 'ignored'; findErrorActions().vm.$emit('update-issue-status', { @@ -459,10 +455,10 @@ describe('ErrorTrackingList', () => { status, }); - setImmediate(() => { - const { category, action } = trackErrorStatusUpdateOptions(status); - expect(Tracking.event).toHaveBeenCalledWith(category, action); - }); + await nextTick(); + + const { category, action } = trackErrorStatusUpdateOptions(status); + expect(Tracking.event).toHaveBeenCalledWith(category, action); }); }); }); |