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

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

describe('Commit form modal mutations', () => {
  let stateCopy;

  describe('REQUEST_BRANCHES', () => {
    it('should set isFetching to true', () => {
      stateCopy = { isFetching: false };

      mutations[types.REQUEST_BRANCHES](stateCopy);

      expect(stateCopy.isFetching).toBe(true);
    });
  });

  describe('RECEIVE_BRANCHES_SUCCESS', () => {
    it('should set branches', () => {
      stateCopy = { branch: '_existing_branch_', isFetching: true };

      mutations[types.RECEIVE_BRANCHES_SUCCESS](stateCopy, ['_branch_1_', '_branch_2_']);

      expect(stateCopy.branches).toEqual(['_existing_branch_', '_branch_1_', '_branch_2_']);
      expect(stateCopy.isFetching).toEqual(false);
    });
  });

  describe('CLEAR_MODAL', () => {
    it('should clear modal state ', () => {
      stateCopy = { branch: '_master_', defaultBranch: '_default_branch_' };

      mutations[types.CLEAR_MODAL](stateCopy);

      expect(stateCopy.branch).toEqual('_default_branch_');
    });
  });

  describe('SET_BRANCH', () => {
    it('should set branch', () => {
      stateCopy = { branch: '_master_' };

      mutations[types.SET_BRANCH](stateCopy, '_changed_branch_');

      expect(stateCopy.branch).toBe('_changed_branch_');
    });
  });

  describe('SET_SELECTED_BRANCH', () => {
    it('should set selectedBranch', () => {
      stateCopy = { selectedBranch: '_master_' };

      mutations[types.SET_SELECTED_BRANCH](stateCopy, '_changed_branch_');

      expect(stateCopy.selectedBranch).toBe('_changed_branch_');
    });
  });
});