diff options
Diffstat (limited to 'spec/frontend/ref/components/ref_selector_spec.js')
-rw-r--r-- | spec/frontend/ref/components/ref_selector_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/ref/components/ref_selector_spec.js b/spec/frontend/ref/components/ref_selector_spec.js index 6b90827f9c2..5e15ba26ece 100644 --- a/spec/frontend/ref/components/ref_selector_spec.js +++ b/spec/frontend/ref/components/ref_selector_spec.js @@ -35,6 +35,7 @@ describe('Ref selector component', () => { const projectId = '8'; const totalBranchesCount = 123; const totalTagsCount = 456; + const queryParams = { sort: 'updated_desc' }; let wrapper; let branchesApiCallSpy; @@ -738,4 +739,25 @@ describe('Ref selector component', () => { expect(lastCallProps.matches).toMatchObject(expectedMatches); }); }); + describe('when queryParam prop is present', () => { + it('passes params to a branches API call', () => { + createComponent({ propsData: { queryParams } }); + + return waitForRequests().then(() => { + expect(branchesApiCallSpy).toHaveBeenCalledWith( + expect.objectContaining({ params: { per_page: 20, search: '', sort: queryParams.sort } }), + ); + }); + }); + + it('does not pass params to tags API call', () => { + createComponent({ propsData: { queryParams } }); + + return waitForRequests().then(() => { + expect(tagsApiCallSpy).toHaveBeenCalledWith( + expect.objectContaining({ params: { per_page: 20, search: '' } }), + ); + }); + }); + }); }); |