Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/work_items/notes/award_utils_spec.js')
-rw-r--r--spec/frontend/work_items/notes/award_utils_spec.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/frontend/work_items/notes/award_utils_spec.js b/spec/frontend/work_items/notes/award_utils_spec.js
index 8ae32ce5f40..43eceb13b67 100644
--- a/spec/frontend/work_items/notes/award_utils_spec.js
+++ b/spec/frontend/work_items/notes/award_utils_spec.js
@@ -2,6 +2,7 @@ import { getMutation, optimisticAwardUpdate } from '~/work_items/notes/award_uti
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import mockApollo from 'helpers/mock_apollo_helper';
import { __ } from '~/locale';
+import groupWorkItemNotesByIidQuery from '~/work_items/graphql/notes/group_work_item_notes_by_iid.query.graphql';
import workItemNotesByIidQuery from '~/work_items/graphql/notes/work_item_notes_by_iid.query.graphql';
import addAwardEmojiMutation from '~/work_items/graphql/notes/work_item_note_add_award_emoji.mutation.graphql';
import removeAwardEmojiMutation from '~/work_items/graphql/notes/work_item_note_remove_award_emoji.mutation.graphql';
@@ -105,5 +106,22 @@ describe('Work item note award utils', () => {
expect(updatedNote.awardEmoji.nodes).toEqual([]);
});
+
+ it.each`
+ description | isGroup | query
+ ${'calls project query when in project context'} | ${false} | ${workItemNotesByIidQuery}
+ ${'calls group query when in group context'} | ${true} | ${groupWorkItemNotesByIidQuery}
+ `('$description', ({ isGroup, query }) => {
+ const note = firstNote;
+ const { name } = mockAwardEmojiThumbsUp;
+ const cacheSpy = { updateQuery: jest.fn() };
+
+ optimisticAwardUpdate({ note, name, fullPath, isGroup, workItemIid })(cacheSpy);
+
+ expect(cacheSpy.updateQuery).toHaveBeenCalledWith(
+ { query, variables: { fullPath, iid: workItemIid } },
+ expect.any(Function),
+ );
+ });
});
});