diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-05 09:09:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-05 09:09:25 +0300 |
commit | 962fbcfb94b13668632de822e3f7a74fb5ecaf68 (patch) | |
tree | 51bebd0983aa06a72af75f7b85c05debd5169037 /spec/frontend/search/topbar/components/project_filter_spec.js | |
parent | 24fca3804098db8d0083d35db1975d198467e9b8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search/topbar/components/project_filter_spec.js')
-rw-r--r-- | spec/frontend/search/topbar/components/project_filter_spec.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/frontend/search/topbar/components/project_filter_spec.js b/spec/frontend/search/topbar/components/project_filter_spec.js index 63b0f882ca4..5afcd281d0c 100644 --- a/spec/frontend/search/topbar/components/project_filter_spec.js +++ b/spec/frontend/search/topbar/components/project_filter_spec.js @@ -51,7 +51,6 @@ describe('ProjectFilter', () => { afterEach(() => { wrapper.destroy(); - wrapper = null; }); const findSearchableDropdown = () => wrapper.find(SearchableDropdown); @@ -89,9 +88,10 @@ describe('ProjectFilter', () => { findSearchableDropdown().vm.$emit('change', ANY_OPTION); }); - it('calls setUrlParams with null, no group id, then calls visitUrl', () => { + it('calls setUrlParams with null, no group id, nav_source null, then calls visitUrl', () => { expect(setUrlParams).toHaveBeenCalledWith({ [PROJECT_DATA.queryParam]: null, + nav_source: null, }); expect(visitUrl).toHaveBeenCalled(); }); @@ -106,10 +106,11 @@ describe('ProjectFilter', () => { findSearchableDropdown().vm.$emit('change', MOCK_PROJECT); }); - it('calls setUrlParams with project id, group id, then calls visitUrl', () => { + it('calls setUrlParams with project id, group id, nav_source null, then calls visitUrl', () => { expect(setUrlParams).toHaveBeenCalledWith({ [GROUP_DATA.queryParam]: MOCK_PROJECT.namespace.id, [PROJECT_DATA.queryParam]: MOCK_PROJECT.id, + nav_source: null, }); expect(visitUrl).toHaveBeenCalled(); }); @@ -157,4 +158,31 @@ describe('ProjectFilter', () => { }); }); }); + + describe.each` + navSource | initialData | callMethod + ${null} | ${null} | ${false} + ${null} | ${MOCK_PROJECT} | ${false} + ${'navbar'} | ${null} | ${false} + ${'navbar'} | ${MOCK_PROJECT} | ${true} + `('onCreate', ({ navSource, initialData, callMethod }) => { + describe(`when nav_source is ${navSource} and ${ + initialData ? 'has' : 'does not have' + } an initial project`, () => { + beforeEach(() => { + createComponent({ query: { ...MOCK_QUERY, nav_source: navSource } }, { initialData }); + }); + + it(`${callMethod ? 'does' : 'does not'} call setFrequentProject`, () => { + if (callMethod) { + expect(actionSpies.setFrequentProject).toHaveBeenCalledWith( + expect.any(Object), + initialData, + ); + } else { + expect(actionSpies.setFrequentProject).not.toHaveBeenCalled(); + } + }); + }); + }); }); |