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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-13 18:08:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-13 18:08:38 +0300
commite1189e4c3b8bd5535104f458f5af7505789eac00 (patch)
tree1a3e2e536e66120c60a6088329349f323de2d14b /spec/frontend/boards/stores/actions_spec.js
parent8ce82c1eaf87d1b22b645e2c37671f01d2c35581 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/boards/stores/actions_spec.js')
-rw-r--r--spec/frontend/boards/stores/actions_spec.js68
1 files changed, 58 insertions, 10 deletions
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js
index 5f8af7cdc60..ebed33e5b34 100644
--- a/spec/frontend/boards/stores/actions_spec.js
+++ b/spec/frontend/boards/stores/actions_spec.js
@@ -492,6 +492,63 @@ describe('moveList', () => {
});
describe('updateList', () => {
+ const listId = 'gid://gitlab/List/1';
+ const createState = (boardItemsByListId = {}) => ({
+ fullPath: 'gitlab-org',
+ fullBoardId: 'gid://gitlab/Board/1',
+ boardType: 'group',
+ disabled: false,
+ boardLists: [{ type: 'closed' }],
+ issuableType: issuableTypes.issue,
+ boardItemsByListId,
+ });
+
+ describe('when state doesnt have list items', () => {
+ it('calls fetchItemsByList', async () => {
+ const dispatch = jest.fn();
+
+ jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
+ data: {
+ updateBoardList: {
+ errors: [],
+ list: {
+ id: listId,
+ },
+ },
+ },
+ });
+
+ await actions.updateList({ commit: () => {}, state: createState(), dispatch }, { listId });
+
+ expect(dispatch.mock.calls).toEqual([['fetchItemsForList', { listId }]]);
+ });
+ });
+
+ describe('when state has list items', () => {
+ it('doesnt call fetchItemsByList', async () => {
+ const commit = jest.fn();
+ const dispatch = jest.fn();
+
+ jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
+ data: {
+ updateBoardList: {
+ errors: [],
+ list: {
+ id: listId,
+ },
+ },
+ },
+ });
+
+ await actions.updateList(
+ { commit, state: createState({ [listId]: [] }), dispatch },
+ { listId },
+ );
+
+ expect(dispatch.mock.calls).toEqual([]);
+ });
+ });
+
it('should commit UPDATE_LIST_FAILURE mutation when API returns an error', (done) => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: {
@@ -502,19 +559,10 @@ describe('updateList', () => {
},
});
- const state = {
- fullPath: 'gitlab-org',
- fullBoardId: 'gid://gitlab/Board/1',
- boardType: 'group',
- disabled: false,
- boardLists: [{ type: 'closed' }],
- issuableType: issuableTypes.issue,
- };
-
testAction(
actions.updateList,
{ listId: 'gid://gitlab/List/1', position: 1 },
- state,
+ createState(),
[{ type: types.UPDATE_LIST_FAILURE }],
[],
done,