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: 60abf0fddad9c4de3565b4fbf9b744375b9945dd (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
import * as types from '~/projects/commit/store/mutation_types';
import mutations from '~/projects/commit/store/mutations';

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: '_main_', defaultBranch: '_default_branch_' };

      mutations[types.CLEAR_MODAL](stateCopy);

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

  describe('SET_BRANCHES_ENDPOINT', () => {
    it('should set branchesEndpoint', () => {
      stateCopy = { branchesEndpoint: 'endpoint/1' };

      mutations[types.SET_BRANCHES_ENDPOINT](stateCopy, 'endpoint/2');

      expect(stateCopy.branchesEndpoint).toBe('endpoint/2');
    });
  });

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

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

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

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

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

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

  describe('SET_SELECTED_PROJECT', () => {
    it('should set targetProjectId', () => {
      stateCopy = { targetProjectId: '_project_1_' };

      mutations[types.SET_SELECTED_PROJECT](stateCopy, '_project_2_');

      expect(stateCopy.targetProjectId).toBe('_project_2_');
    });
  });
});