diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 06:09:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 06:09:27 +0300 |
commit | 39623d60e828f0d9e2d9c96fa5adfc420808f454 (patch) | |
tree | 69abb57cb958e3c8f6e279c9adb26db10184444d /spec/frontend/search/topbar/components | |
parent | 5da9546a43ffba2fabdd87c7abcf1a32e2ed0965 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search/topbar/components')
3 files changed, 49 insertions, 26 deletions
diff --git a/spec/frontend/search/topbar/components/group_filter_spec.js b/spec/frontend/search/topbar/components/group_filter_spec.js index 3b460402537..21f18bb6864 100644 --- a/spec/frontend/search/topbar/components/group_filter_spec.js +++ b/spec/frontend/search/topbar/components/group_filter_spec.js @@ -64,12 +64,14 @@ describe('GroupFilter', () => { }); describe('events', () => { + beforeEach(() => { + createComponent(); + }); + describe('when @search is emitted', () => { const search = 'test'; beforeEach(() => { - createComponent(); - findSearchableDropdown().vm.$emit('search', search); }); @@ -81,8 +83,6 @@ describe('GroupFilter', () => { describe('when @change is emitted with Any', () => { beforeEach(() => { - createComponent(); - findSearchableDropdown().vm.$emit('change', ANY_OPTION); }); @@ -102,8 +102,6 @@ describe('GroupFilter', () => { describe('when @change is emitted with a group', () => { beforeEach(() => { - createComponent(); - findSearchableDropdown().vm.$emit('change', MOCK_GROUP); }); @@ -120,6 +118,16 @@ describe('GroupFilter', () => { expect(actionSpies.setFrequentGroup).toHaveBeenCalledWith(expect.any(Object), MOCK_GROUP); }); }); + + describe('when @first-open is emitted', () => { + beforeEach(() => { + findSearchableDropdown().vm.$emit('first-open'); + }); + + it('calls loadFrequentGroups', () => { + expect(actionSpies.loadFrequentGroups).toHaveBeenCalledTimes(1); + }); + }); }); describe('computed', () => { @@ -145,14 +153,4 @@ describe('GroupFilter', () => { }); }); }); - - describe('onCreate', () => { - beforeEach(() => { - createComponent(); - }); - - it('calls loadFrequentGroups', () => { - expect(actionSpies.loadFrequentGroups).toHaveBeenCalledTimes(1); - }); - }); }); diff --git a/spec/frontend/search/topbar/components/project_filter_spec.js b/spec/frontend/search/topbar/components/project_filter_spec.js index d260df4120b..ecc9273395f 100644 --- a/spec/frontend/search/topbar/components/project_filter_spec.js +++ b/spec/frontend/search/topbar/components/project_filter_spec.js @@ -119,6 +119,16 @@ describe('ProjectFilter', () => { }); }); }); + + describe('when @first-open is emitted', () => { + beforeEach(() => { + findSearchableDropdown().vm.$emit('first-open'); + }); + + it('calls loadFrequentProjects', () => { + expect(actionSpies.loadFrequentProjects).toHaveBeenCalledTimes(1); + }); + }); }); describe('computed', () => { @@ -144,14 +154,4 @@ describe('ProjectFilter', () => { }); }); }); - - describe('onCreate', () => { - beforeEach(() => { - createComponent(); - }); - - it('calls loadFrequentProjects', () => { - expect(actionSpies.loadFrequentProjects).toHaveBeenCalledTimes(1); - }); - }); }); diff --git a/spec/frontend/search/topbar/components/searchable_dropdown_spec.js b/spec/frontend/search/topbar/components/searchable_dropdown_spec.js index 10d779f0f90..2ad46eeeb1e 100644 --- a/spec/frontend/search/topbar/components/searchable_dropdown_spec.js +++ b/spec/frontend/search/topbar/components/searchable_dropdown_spec.js @@ -159,5 +159,30 @@ describe('Global Search Searchable Dropdown', () => { expect(wrapper.emitted('change')[0]).toEqual([MOCK_GROUPS[0]]); }); + + describe('opening the dropdown', () => { + describe('for the first time', () => { + beforeEach(() => { + findGlDropdown().vm.$emit('show'); + }); + + it('$emits @search and @first-open', () => { + expect(wrapper.emitted('search')[0]).toStrictEqual([wrapper.vm.searchText]); + expect(wrapper.emitted('first-open')[0]).toStrictEqual([]); + }); + }); + + describe('not for the first time', () => { + beforeEach(() => { + wrapper.setData({ hasBeenOpened: true }); + findGlDropdown().vm.$emit('show'); + }); + + it('$emits @search and not @first-open', () => { + expect(wrapper.emitted('search')[0]).toStrictEqual([wrapper.vm.searchText]); + expect(wrapper.emitted('first-open')).toBeUndefined(); + }); + }); + }); }); }); |