diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 03:17:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 03:17:46 +0300 |
commit | 270353e1ff556a43333f82f171c3a485958126f0 (patch) | |
tree | c7bb4ac335b1e101b9bf92905ec2e8e170c6696c /spec/frontend/search | |
parent | b2e3da6a38f143a8c782dae4baceae3ed764733d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search')
-rw-r--r-- | spec/frontend/search/mock_data.js | 75 | ||||
-rw-r--r-- | spec/frontend/search/store/getters_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/search/store/utils_spec.js | 15 |
3 files changed, 98 insertions, 0 deletions
diff --git a/spec/frontend/search/mock_data.js b/spec/frontend/search/mock_data.js index 9ca170d34e2..f8dd6f6df27 100644 --- a/spec/frontend/search/mock_data.js +++ b/spec/frontend/search/mock_data.js @@ -467,3 +467,78 @@ export const SMALL_MOCK_AGGREGATIONS = [ buckets: TEST_RAW_BUCKETS, }, ]; + +export const MOCK_NAVIGATION_ITEMS = [ + { + title: 'Projects', + icon: 'project', + link: '/search?scope=projects&search=et', + is_active: false, + pill_count: '10K+', + items: [], + }, + { + title: 'Code', + icon: 'code', + link: '/search?scope=blobs&search=et', + is_active: false, + pill_count: '0', + items: [], + }, + { + title: 'Issues', + icon: 'issues', + link: '/search?scope=issues&search=et', + is_active: true, + pill_count: '2.4K', + items: [], + }, + { + title: 'Merge requests', + icon: 'merge-request', + link: '/search?scope=merge_requests&search=et', + is_active: false, + pill_count: '0', + items: [], + }, + { + title: 'Wiki', + icon: 'overview', + link: '/search?scope=wiki_blobs&search=et', + is_active: false, + pill_count: '0', + items: [], + }, + { + title: 'Commits', + icon: 'commit', + link: '/search?scope=commits&search=et', + is_active: false, + pill_count: '0', + items: [], + }, + { + title: 'Comments', + icon: 'comments', + link: '/search?scope=notes&search=et', + is_active: false, + pill_count: '0', + items: [], + }, + { + title: 'Milestones', + icon: 'tag', + link: '/search?scope=milestones&search=et', + is_active: false, + pill_count: '0', + items: [], + }, + { + title: 'Users', + icon: 'users', + link: '/search?scope=users&search=et', + is_active: false, + pill_count: '0', + items: [], + }, +]; diff --git a/spec/frontend/search/store/getters_spec.js b/spec/frontend/search/store/getters_spec.js index 0ef0922c4b0..e3b8e7575a4 100644 --- a/spec/frontend/search/store/getters_spec.js +++ b/spec/frontend/search/store/getters_spec.js @@ -10,6 +10,7 @@ import { MOCK_LANGUAGE_AGGREGATIONS_BUCKETS, TEST_FILTER_DATA, MOCK_NAVIGATION, + MOCK_NAVIGATION_ITEMS, } from '../mock_data'; describe('Global Search Store Getters', () => { @@ -68,4 +69,11 @@ describe('Global Search Store Getters', () => { expect(getters.currentUrlQueryHasLanguageFilters(state)).toBe(result); }); }); + + describe('navigationItems', () => { + it('returns the re-mapped navigation data', () => { + state.navigation = MOCK_NAVIGATION; + expect(getters.navigationItems(state)).toStrictEqual(MOCK_NAVIGATION_ITEMS); + }); + }); }); diff --git a/spec/frontend/search/store/utils_spec.js b/spec/frontend/search/store/utils_spec.js index dfe4e801f11..802c5219799 100644 --- a/spec/frontend/search/store/utils_spec.js +++ b/spec/frontend/search/store/utils_spec.js @@ -8,6 +8,7 @@ import { formatSearchResultCount, getAggregationsUrl, prepareSearchAggregations, + addCountOverLimit, } from '~/search/store/utils'; import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import { @@ -288,4 +289,18 @@ describe('Global Search Store Utils', () => { expect(prepareSearchAggregations({ query }, data)).toStrictEqual(result); }); }); + + describe('addCountOverLimit', () => { + it("should return '+' if count includes '+'", () => { + expect(addCountOverLimit('10+')).toEqual('+'); + }); + + it("should return empty string if count does not include '+'", () => { + expect(addCountOverLimit('10')).toEqual(''); + }); + + it('should return empty string if count is not provided', () => { + expect(addCountOverLimit()).toEqual(''); + }); + }); }); |