diff options
Diffstat (limited to 'spec/frontend/search/store/utils_spec.js')
-rw-r--r-- | spec/frontend/search/store/utils_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/search/store/utils_spec.js b/spec/frontend/search/store/utils_spec.js index 20d764190b1..487ed7bfe03 100644 --- a/spec/frontend/search/store/utils_spec.js +++ b/spec/frontend/search/store/utils_spec.js @@ -5,7 +5,10 @@ import { setFrequentItemToLS, mergeById, isSidebarDirty, + formatSearchResultCount, + getAggregationsUrl, } from '~/search/store/utils'; +import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import { MOCK_LS_KEY, MOCK_GROUPS, @@ -241,4 +244,23 @@ describe('Global Search Store Utils', () => { }); }); }); + describe('formatSearchResultCount', () => { + it('returns zero as string if no count is provided', () => { + expect(formatSearchResultCount()).toStrictEqual('0'); + }); + it('returns 10K string for 10000 integer', () => { + expect(formatSearchResultCount(10000)).toStrictEqual('10K'); + }); + it('returns 23K string for "23,000+" string', () => { + expect(formatSearchResultCount('23,000+')).toStrictEqual('23K'); + }); + }); + + describe('getAggregationsUrl', () => { + useMockLocationHelper(); + it('returns zero as string if no count is provided', () => { + const testURL = window.location.href; + expect(getAggregationsUrl()).toStrictEqual(`${testURL}search/aggregations`); + }); + }); }); |