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

mutations_spec.js « new « store « user_lists « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 89e8a83eb25b3ce0b17e3319a3fc12ac4f304400 (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
import createState from '~/user_lists/store/new/state';
import * as types from '~/user_lists/store/new/mutation_types';
import mutations from '~/user_lists/store/new/mutations';

describe('User List Edit Mutations', () => {
  let state;

  beforeEach(() => {
    state = createState({ projectId: '1' });
  });

  describe(types.RECIEVE_USER_LIST_ERROR, () => {
    beforeEach(() => {
      mutations[types.RECEIVE_CREATE_USER_LIST_ERROR](state, ['network error']);
    });

    it('sets the error message to the recieved one', () => {
      expect(state.errorMessage).toEqual(['network error']);
    });

    it('sets the error message to the recevied API message if present', () => {
      const message = ['name is blank', 'name is too short'];

      mutations[types.RECEIVE_CREATE_USER_LIST_ERROR](state, message);
      expect(state.errorMessage).toEqual(message);
    });
  });

  describe(types.DISMISS_ERROR_ALERT, () => {
    beforeEach(() => {
      mutations[types.DISMISS_ERROR_ALERT](state);
    });

    it('clears the error message', () => {
      expect(state.errorMessage).toBe('');
    });
  });
});