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/issues/list/utils_spec.js | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/issues/list/utils_spec.js')
-rw-r--r-- | spec/frontend/issues/list/utils_spec.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/frontend/issues/list/utils_spec.js b/spec/frontend/issues/list/utils_spec.js index a60350d91c5..ce0477883d7 100644 --- a/spec/frontend/issues/list/utils_spec.js +++ b/spec/frontend/issues/list/utils_spec.js @@ -1,3 +1,5 @@ +import setWindowLocation from 'helpers/set_window_location_helper'; +import { TEST_HOST } from 'helpers/test_constants'; import { apiParams, apiParamsWithSpecialValues, @@ -24,6 +26,7 @@ import { getSortOptions, isSortKey, } from '~/issues/list/utils'; +import { FILTERED_SEARCH_TERM } from '~/vue_shared/components/filtered_search_bar/constants'; describe('getInitialPageParams', () => { it.each(Object.keys(urlSortParams))( @@ -124,24 +127,50 @@ describe('getFilterTokens', () => { filteredTokensWithSpecialValues, ); }); + + it.each` + description | argument + ${'an undefined value'} | ${undefined} + ${'an irrelevant value'} | ${'?unrecognised=parameter'} + `('returns an empty filtered search term given $description', ({ argument }) => { + expect(getFilterTokens(argument)).toEqual([ + { + id: expect.any(String), + type: FILTERED_SEARCH_TERM, + value: { data: '' }, + }, + ]); + }); }); describe('convertToApiParams', () => { + beforeEach(() => { + setWindowLocation(TEST_HOST); + }); + it('returns api params given filtered tokens', () => { expect(convertToApiParams(filteredTokens)).toEqual(apiParams); }); it('returns api params given filtered tokens with special values', () => { + setWindowLocation('?assignee_id=123'); + expect(convertToApiParams(filteredTokensWithSpecialValues)).toEqual(apiParamsWithSpecialValues); }); }); describe('convertToUrlParams', () => { + beforeEach(() => { + setWindowLocation(TEST_HOST); + }); + it('returns url params given filtered tokens', () => { expect(convertToUrlParams(filteredTokens)).toEqual(urlParams); }); it('returns url params given filtered tokens with special values', () => { + setWindowLocation('?assignee_id=123'); + expect(convertToUrlParams(filteredTokensWithSpecialValues)).toEqual(urlParamsWithSpecialValues); }); }); |