diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/filtered_search_bar/tokens')
4 files changed, 21 insertions, 26 deletions
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js index 88618de6979..1d6834a5604 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js @@ -156,9 +156,12 @@ describe('BaseToken', () => { it('uses last item in list when value is an array', () => { const mockGetActiveTokenValue = jest.fn(); + const config = { ...mockConfig, multiSelect: true }; + wrapper = createComponent({ props: { - value: { data: mockLabels.map((l) => l.title) }, + config, + value: { data: mockLabels.map((l) => l.title), operator: '||' }, suggestions: mockLabels, getActiveTokenValue: mockGetActiveTokenValue, }, @@ -409,8 +412,9 @@ describe('BaseToken', () => { }); it('emits token-selected event when groupMultiSelectTokens: true', () => { + const config = { ...mockConfig, multiSelect: true }; wrapper = createComponent({ - props: { suggestions: mockLabels }, + props: { suggestions: mockLabels, config, value: { operator: '||' } }, groupMultiSelectTokens: true, }); @@ -419,9 +423,10 @@ describe('BaseToken', () => { expect(wrapper.emitted('token-selected')).toEqual([[mockTokenValue.title]]); }); - it('does not emit token-selected event when groupMultiSelectTokens: true', () => { + it('does not emit token-selected event when groupMultiSelectTokens: false', () => { + const config = { ...mockConfig, multiSelect: true }; wrapper = createComponent({ - props: { suggestions: mockLabels }, + props: { suggestions: mockLabels, config, value: { operator: '||' } }, groupMultiSelectTokens: false, }); diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/date_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/date_token_spec.js index 56a59790210..34d0c7f0566 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/date_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/date_token_spec.js @@ -42,7 +42,7 @@ describe('DateToken', () => { findDatepicker().vm.$emit('close'); expect(findGlFilteredSearchToken().emitted()).toEqual({ - complete: [[]], + complete: [['2014-10-13']], select: [['2014-10-13']], }); }); diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js index 36e82b39df4..ee54fb5b941 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js @@ -5,15 +5,12 @@ import { GlDropdownDivider, } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; -import MockAdapter from 'axios-mock-adapter'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { createAlert } from '~/alert'; -import axios from '~/lib/utils/axios_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils'; - import searchMilestonesQuery from '~/issues/list/queries/search_milestones.query.graphql'; import { DEFAULT_MILESTONES } from '~/vue_shared/components/filtered_search_bar/constants'; import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue'; @@ -70,7 +67,6 @@ function createComponent(options = {}) { } describe('MilestoneToken', () => { - let mock; let wrapper; const findBaseToken = () => wrapper.findComponent(BaseToken); @@ -80,14 +76,9 @@ describe('MilestoneToken', () => { }; beforeEach(() => { - mock = new MockAdapter(axios); wrapper = createComponent(); }); - afterEach(() => { - mock.restore(); - }); - describe('methods', () => { describe('fetchMilestones', () => { it('sets loading state', async () => { diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/user_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/user_token_spec.js index 4462d1bfaf5..decf843091e 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/user_token_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/user_token_spec.js @@ -313,11 +313,11 @@ describe('UserToken', () => { describe('multiSelect', () => { it('renders check icons in suggestions when multiSelect is true', async () => { wrapper = createComponent({ - value: { data: [mockUsers[0].username, mockUsers[1].username], operator: '=' }, + value: { data: [mockUsers[0].username, mockUsers[1].username], operator: '||' }, data: { users: mockUsers, }, - config: { ...mockAuthorToken, multiSelect: true, initialUsers: mockUsers }, + config: { ...mockAuthorToken, multiSelect: true }, active: true, stubs: { Portal: true }, groupMultiSelectTokens: true, @@ -327,18 +327,17 @@ describe('UserToken', () => { const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion); - expect(findIconAtSuggestion(1).exists()).toBe(false); - expect(findIconAtSuggestion(2).props('name')).toBe('check'); - expect(findIconAtSuggestion(3).props('name')).toBe('check'); + expect(findIconAtSuggestion(0).props('name')).toBe('check'); + expect(findIconAtSuggestion(1).props('name')).toBe('check'); + expect(findIconAtSuggestion(2).exists()).toBe(false); // test for left padding on unchecked items (so alignment is correct) - expect(findIconAtSuggestion(4).exists()).toBe(false); - expect(suggestions.at(4).find('.gl-pl-6').exists()).toBe(true); + expect(suggestions.at(2).find('.gl-pl-6').exists()).toBe(true); }); it('renders multiple users when multiSelect is true', async () => { wrapper = createComponent({ - value: { data: [mockUsers[0].username, mockUsers[1].username], operator: '=' }, + value: { data: [mockUsers[0].username, mockUsers[1].username], operator: '||' }, data: { users: mockUsers, }, @@ -363,7 +362,7 @@ describe('UserToken', () => { it('adds new user to multi-select-values', () => { wrapper = createComponent({ - value: { data: [mockUsers[0].username], operator: '=' }, + value: { data: [mockUsers[0].username], operator: '||' }, data: { users: mockUsers, }, @@ -383,7 +382,7 @@ describe('UserToken', () => { it('removes existing user from array', () => { const initialUsers = [mockUsers[0].username, mockUsers[1].username]; wrapper = createComponent({ - value: { data: initialUsers, operator: '=' }, + value: { data: initialUsers, operator: '||' }, data: { users: mockUsers, }, @@ -399,7 +398,7 @@ describe('UserToken', () => { it('clears input field after token selected', () => { wrapper = createComponent({ - value: { data: [mockUsers[0].username, mockUsers[1].username], operator: '=' }, + value: { data: [mockUsers[0].username, mockUsers[1].username], operator: '||' }, data: { users: mockUsers, }, @@ -410,7 +409,7 @@ describe('UserToken', () => { findBaseToken().vm.$emit('token-selected', 'test'); - expect(wrapper.emitted('input')).toEqual([[{ operator: '=', data: '' }]]); + expect(wrapper.emitted('input')).toEqual([[{ operator: '||', data: '' }]]); }); }); |