summaryrefslogtreecommitdiff
path: root/spec/javascripts/ide/stores/mutations/branch_spec.js
blob: f2f1f2a9a2e3a529319c7dc803113461c5a08613 (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
import mutations from '~/ide/stores/mutations/branch';
import state from '~/ide/stores/state';

describe('Multi-file store branch mutations', () => {
  let localState;

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

  describe('SET_CURRENT_BRANCH', () => {
    it('sets currentBranch', () => {
      mutations.SET_CURRENT_BRANCH(localState, 'master');

      expect(localState.currentBranchId).toBe('master');
    });
  });

  describe('SET_BRANCH_COMMIT', () => {
    it('sets the last commit on current project', () => {
      localState.projects = {
        Example: {
          branches: {
            master: {},
          },
        },
      };

      mutations.SET_BRANCH_COMMIT(localState, {
        projectId: 'Example',
        branchId: 'master',
        commit: {
          title: 'Example commit',
        },
      });

      expect(localState.projects.Example.branches.master.commit.title).toBe('Example commit');
    });
  });

  describe('SET_LAST_COMMIT_PIPELINE', () => {
    it('sets the pipeline for the last commit on current project', () => {
      localState.projects = {
        Example: {
          branches: {
            master: {
              commit: {},
            },
          },
        },
      };

      mutations.SET_LAST_COMMIT_PIPELINE(localState, {
        projectId: 'Example',
        branchId: 'master',
        pipeline: {
          id: '50',
          details: {
            status: {
              icon: 'status_passed',
              text: 'passed',
            },
          },
        },
      });

      expect(localState.projects.Example.branches.master.commit.pipeline.id).toBe('50');
      expect(localState.projects.Example.branches.master.commit.pipeline.details.status.text).toBe(
        'passed',
      );
      expect(localState.projects.Example.branches.master.commit.pipeline.details.status.icon).toBe(
        'status_passed',
      );
    });
  });
});