diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/frontend/vue_shared/components/user_select_spec.js | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/frontend/vue_shared/components/user_select_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/user_select_spec.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/spec/frontend/vue_shared/components/user_select_spec.js b/spec/frontend/vue_shared/components/user_select_spec.js index 5a609568220..0fabc6525ea 100644 --- a/spec/frontend/vue_shared/components/user_select_spec.js +++ b/spec/frontend/vue_shared/components/user_select_spec.js @@ -49,10 +49,13 @@ describe('User select dropdown', () => { const findUnassignLink = () => wrapper.find('[data-testid="unassign"]'); const findEmptySearchResults = () => wrapper.find('[data-testid="empty-results"]'); + const searchQueryHandlerSuccess = jest.fn().mockResolvedValue(projectMembersResponse); + const participantsQueryHandlerSuccess = jest.fn().mockResolvedValue(participantsQueryResponse); + const createComponent = ({ props = {}, - searchQueryHandler = jest.fn().mockResolvedValue(projectMembersResponse), - participantsQueryHandler = jest.fn().mockResolvedValue(participantsQueryResponse), + searchQueryHandler = searchQueryHandlerSuccess, + participantsQueryHandler = participantsQueryHandlerSuccess, } = {}) => { fakeApollo = createMockApollo([ [searchUsersQuery, searchQueryHandler], @@ -91,6 +94,14 @@ describe('User select dropdown', () => { expect(findParticipantsLoading().exists()).toBe(true); }); + it('skips the queries if `isEditing` prop is false', () => { + createComponent({ props: { isEditing: false } }); + + expect(findParticipantsLoading().exists()).toBe(false); + expect(searchQueryHandlerSuccess).not.toHaveBeenCalled(); + expect(participantsQueryHandlerSuccess).not.toHaveBeenCalled(); + }); + it('emits an `error` event if participants query was rejected', async () => { createComponent({ participantsQueryHandler: mockError }); await waitForPromises(); |