diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-08 06:10:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-08 06:10:33 +0000 |
commit | df3831073fc66d2ef346dc0ae99a541267acf83d (patch) | |
tree | 7f71ac9e26dcf9186470be9b979d9657da38dcd8 /spec | |
parent | bc6937b797cbdca20b46cc0312cf284ed6723c71 (diff) | |
download | gitlab-ce-df3831073fc66d2ef346dc0ae99a541267acf83d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/vue_shared/components/project_selector/project_selector_spec.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/spec/frontend/vue_shared/components/project_selector/project_selector_spec.js b/spec/frontend/vue_shared/components/project_selector/project_selector_spec.js index 662192edd8c..016622fd0bb 100644 --- a/spec/frontend/vue_shared/components/project_selector/project_selector_spec.js +++ b/spec/frontend/vue_shared/components/project_selector/project_selector_spec.js @@ -18,6 +18,13 @@ describe('ProjectSelector component', () => { selected = selected.concat(allProjects.slice(0, 3)).concat(allProjects.slice(5, 8)); const findSearchInput = () => wrapper.find(GlSearchBoxByType).find('input'); + const findLegendText = () => wrapper.find('[data-testid="legend-text"]').text(); + const search = (query) => { + const searchInput = findSearchInput(); + + searchInput.setValue(query); + searchInput.trigger('input'); + }; beforeEach(() => { wrapper = mount(Vue.extend(ProjectSelector), { @@ -48,10 +55,7 @@ describe('ProjectSelector component', () => { it(`triggers a search when the search input value changes`, () => { jest.spyOn(vm, '$emit').mockImplementation(() => {}); const query = 'my test query!'; - const searchInput = findSearchInput(); - - searchInput.setValue(query); - searchInput.trigger('input'); + search(query); expect(vm.$emit).toHaveBeenCalledWith('searched', query); }); @@ -121,15 +125,21 @@ describe('ProjectSelector component', () => { `( 'is "$expected" given $count results are showing out of $total', ({ count, total, expected }) => { + search('gitlab ui'); + wrapper.setProps({ projectSearchResults: searchResults.slice(0, count), totalResults: total, }); return wrapper.vm.$nextTick().then(() => { - expect(wrapper.text()).toContain(expected); + expect(findLegendText()).toBe(expected); }); }, ); + + it('is not rendered without searching', () => { + expect(findLegendText()).toBe(''); + }); }); }); |