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

mutations_spec.js « stores « boards « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c1f7f3dda6e1ab4f91118831a6c15240699d0921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import mutations from '~/boards/stores/mutations';
import defaultState from '~/boards/stores/state';
import { mockIssue } from '../mock_data';

const expectNotImplemented = action => {
  it('is not implemented', () => {
    expect(action).toThrow(new Error('Not implemented!'));
  });
};

describe('Board Store Mutations', () => {
  let state;

  beforeEach(() => {
    state = defaultState();
  });

  describe('SET_INITIAL_BOARD_DATA', () => {
    it('Should set initial Boards data to state', () => {
      const endpoints = {
        boardsEndpoint: '/boards/',
        recentBoardsEndpoint: '/boards/',
        listsEndpoint: '/boards/lists',
        bulkUpdatePath: '/boards/bulkUpdate',
        boardId: 1,
        fullPath: 'gitlab-org',
      };
      const boardType = 'group';

      mutations.SET_INITIAL_BOARD_DATA(state, { ...endpoints, boardType });

      expect(state.endpoints).toEqual(endpoints);
      expect(state.boardType).toEqual(boardType);
    });
  });

  describe('SET_ACTIVE_ID', () => {
    it('updates activeListId to be the value that is passed', () => {
      const expectedId = 1;

      mutations.SET_ACTIVE_ID(state, expectedId);

      expect(state.activeId).toBe(expectedId);
    });
  });

  describe('REQUEST_ADD_LIST', () => {
    expectNotImplemented(mutations.REQUEST_ADD_LIST);
  });

  describe('RECEIVE_ADD_LIST_SUCCESS', () => {
    expectNotImplemented(mutations.RECEIVE_ADD_LIST_SUCCESS);
  });

  describe('RECEIVE_ADD_LIST_ERROR', () => {
    expectNotImplemented(mutations.RECEIVE_ADD_LIST_ERROR);
  });

  describe('REQUEST_UPDATE_LIST', () => {
    expectNotImplemented(mutations.REQUEST_UPDATE_LIST);
  });

  describe('RECEIVE_UPDATE_LIST_SUCCESS', () => {
    expectNotImplemented(mutations.RECEIVE_UPDATE_LIST_SUCCESS);
  });

  describe('RECEIVE_UPDATE_LIST_ERROR', () => {
    expectNotImplemented(mutations.RECEIVE_UPDATE_LIST_ERROR);
  });

  describe('REQUEST_REMOVE_LIST', () => {
    expectNotImplemented(mutations.REQUEST_REMOVE_LIST);
  });

  describe('RECEIVE_REMOVE_LIST_SUCCESS', () => {
    expectNotImplemented(mutations.RECEIVE_REMOVE_LIST_SUCCESS);
  });

  describe('RECEIVE_REMOVE_LIST_ERROR', () => {
    expectNotImplemented(mutations.RECEIVE_REMOVE_LIST_ERROR);
  });

  describe('REQUEST_ISSUES_FOR_ALL_LISTS', () => {
    it('sets isLoadingIssues to true', () => {
      expect(state.isLoadingIssues).toBe(false);

      mutations.REQUEST_ISSUES_FOR_ALL_LISTS(state);

      expect(state.isLoadingIssues).toBe(true);
    });
  });

  describe('RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS', () => {
    it('sets isLoadingIssues to false and updates issuesByListId object', () => {
      const listIssues = {
        '1': [mockIssue],
      };

      state = {
        ...state,
        isLoadingIssues: true,
        issuesByListId: {},
      };

      mutations.RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS(state, listIssues);

      expect(state.isLoadingIssues).toBe(false);
      expect(state.issuesByListId).toEqual(listIssues);
    });
  });

  describe('REQUEST_ADD_ISSUE', () => {
    expectNotImplemented(mutations.REQUEST_ADD_ISSUE);
  });

  describe('RECEIVE_ADD_ISSUE_SUCCESS', () => {
    expectNotImplemented(mutations.RECEIVE_ADD_ISSUE_SUCCESS);
  });

  describe('RECEIVE_ADD_ISSUE_ERROR', () => {
    expectNotImplemented(mutations.RECEIVE_ADD_ISSUE_ERROR);
  });

  describe('REQUEST_MOVE_ISSUE', () => {
    expectNotImplemented(mutations.REQUEST_MOVE_ISSUE);
  });

  describe('RECEIVE_MOVE_ISSUE_SUCCESS', () => {
    expectNotImplemented(mutations.RECEIVE_MOVE_ISSUE_SUCCESS);
  });

  describe('RECEIVE_MOVE_ISSUE_ERROR', () => {
    expectNotImplemented(mutations.RECEIVE_MOVE_ISSUE_ERROR);
  });

  describe('REQUEST_UPDATE_ISSUE', () => {
    expectNotImplemented(mutations.REQUEST_UPDATE_ISSUE);
  });

  describe('RECEIVE_UPDATE_ISSUE_SUCCESS', () => {
    expectNotImplemented(mutations.RECEIVE_UPDATE_ISSUE_SUCCESS);
  });

  describe('RECEIVE_UPDATE_ISSUE_ERROR', () => {
    expectNotImplemented(mutations.RECEIVE_UPDATE_ISSUE_ERROR);
  });

  describe('SET_CURRENT_PAGE', () => {
    expectNotImplemented(mutations.SET_CURRENT_PAGE);
  });

  describe('TOGGLE_EMPTY_STATE', () => {
    expectNotImplemented(mutations.TOGGLE_EMPTY_STATE);
  });
});