diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js index 1b9ca8e6092..b0e393bbf5e 100644 --- a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js +++ b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js @@ -13,7 +13,10 @@ import RecentSearchesService from '~/filtered_search/services/recent_searches_se import RecentSearchesStore from '~/filtered_search/stores/recent_searches_store'; import { FILTERED_SEARCH_TERM, - SortDirection, + SORT_DIRECTION, + TOKEN_TYPE_AUTHOR, + TOKEN_TYPE_LABEL, + TOKEN_TYPE_MILESTONE, } from '~/vue_shared/components/filtered_search_bar/constants'; import FilteredSearchBarRoot from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue'; import { uniqueTokens } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils'; @@ -87,7 +90,7 @@ describe('FilteredSearchBarRoot', () => { it('initializes `filterValue`, `selectedSortOption` and `selectedSortDirection` data props and displays the sort dropdown', () => { expect(wrapper.vm.filterValue).toEqual([]); expect(wrapper.vm.selectedSortOption).toBe(mockSortOptions[0]); - expect(wrapper.vm.selectedSortDirection).toBe(SortDirection.descending); + expect(wrapper.vm.selectedSortDirection).toBe(SORT_DIRECTION.descending); expect(wrapper.findComponent(GlButtonGroup).exists()).toBe(true); expect(wrapper.findComponent(GlButton).exists()).toBe(true); expect(wrapper.findComponent(GlDropdown).exists()).toBe(true); @@ -110,9 +113,9 @@ describe('FilteredSearchBarRoot', () => { describe('tokenSymbols', () => { it('returns a map containing type and symbols from `tokens` prop', () => { expect(wrapper.vm.tokenSymbols).toEqual({ - author_username: '@', - label_name: '~', - milestone_title: '%', + [TOKEN_TYPE_AUTHOR]: '@', + [TOKEN_TYPE_LABEL]: '~', + [TOKEN_TYPE_MILESTONE]: '%', }); }); }); @@ -120,9 +123,9 @@ describe('FilteredSearchBarRoot', () => { describe('tokenTitles', () => { it('returns a map containing type and title from `tokens` prop', () => { expect(wrapper.vm.tokenTitles).toEqual({ - author_username: 'Author', - label_name: 'Label', - milestone_title: 'Milestone', + [TOKEN_TYPE_AUTHOR]: 'Author', + [TOKEN_TYPE_LABEL]: 'Label', + [TOKEN_TYPE_MILESTONE]: 'Milestone', }); }); }); @@ -132,7 +135,7 @@ describe('FilteredSearchBarRoot', () => { // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // eslint-disable-next-line no-restricted-syntax wrapper.setData({ - selectedSortDirection: SortDirection.ascending, + selectedSortDirection: SORT_DIRECTION.ascending, }); expect(wrapper.vm.sortDirectionIcon).toBe('sort-lowest'); @@ -142,7 +145,7 @@ describe('FilteredSearchBarRoot', () => { // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // eslint-disable-next-line no-restricted-syntax wrapper.setData({ - selectedSortDirection: SortDirection.descending, + selectedSortDirection: SORT_DIRECTION.descending, }); expect(wrapper.vm.sortDirectionIcon).toBe('sort-highest'); @@ -154,7 +157,7 @@ describe('FilteredSearchBarRoot', () => { // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // eslint-disable-next-line no-restricted-syntax wrapper.setData({ - selectedSortDirection: SortDirection.ascending, + selectedSortDirection: SORT_DIRECTION.ascending, }); expect(wrapper.vm.sortDirectionTooltip).toBe('Sort direction: Ascending'); @@ -164,7 +167,7 @@ describe('FilteredSearchBarRoot', () => { // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // eslint-disable-next-line no-restricted-syntax wrapper.setData({ - selectedSortDirection: SortDirection.descending, + selectedSortDirection: SORT_DIRECTION.descending, }); expect(wrapper.vm.sortDirectionTooltip).toBe('Sort direction: Descending'); @@ -272,11 +275,11 @@ describe('FilteredSearchBarRoot', () => { }); it('sets `selectedSortDirection` to be opposite of its current value', () => { - expect(wrapper.vm.selectedSortDirection).toBe(SortDirection.descending); + expect(wrapper.vm.selectedSortDirection).toBe(SORT_DIRECTION.descending); wrapper.vm.handleSortDirectionClick(); - expect(wrapper.vm.selectedSortDirection).toBe(SortDirection.ascending); + expect(wrapper.vm.selectedSortDirection).toBe(SORT_DIRECTION.ascending); }); it('emits component event `onSort` with opposite of currently selected sort by value', () => { @@ -384,7 +387,7 @@ describe('FilteredSearchBarRoot', () => { // eslint-disable-next-line no-restricted-syntax wrapper.setData({ selectedSortOption: mockSortOptions[0], - selectedSortDirection: SortDirection.descending, + selectedSortDirection: SORT_DIRECTION.descending, recentSearches: mockHistoryItems, }); |