summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/user_select_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/vue_shared/components/user_select_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/user_select_spec.js15
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();