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

merge_request_spec.js « mutations « stores « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: afbe6770c0dbd50a1d009a212b7b24815f681cd3 (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
import mutations from '~/ide/stores/mutations/merge_request';
import state from '~/ide/stores/state';

describe('IDE store merge request mutations', () => {
  let localState;

  beforeEach(() => {
    localState = state();
    localState.projects = { abcproject: { mergeRequests: {} } };

    mutations.SET_MERGE_REQUEST(localState, {
      projectPath: 'abcproject',
      mergeRequestId: 1,
      mergeRequest: {
        title: 'mr',
      },
    });
  });

  describe('SET_CURRENT_MERGE_REQUEST', () => {
    it('sets current merge request', () => {
      mutations.SET_CURRENT_MERGE_REQUEST(localState, 2);

      expect(localState.currentMergeRequestId).toBe(2);
    });
  });

  describe('SET_MERGE_REQUEST', () => {
    it('setsmerge request data', () => {
      const newMr = localState.projects.abcproject.mergeRequests[1];

      expect(newMr.title).toBe('mr');
      expect(newMr.active).toBeTruthy();
    });

    it('keeps original data', () => {
      const versions = ['change'];
      const mergeRequest = localState.projects.abcproject.mergeRequests[1];

      mergeRequest.versions = versions;

      mutations.SET_MERGE_REQUEST(localState, {
        projectPath: 'abcproject',
        mergeRequestId: 1,
        mergeRequest: {
          title: ['change'],
        },
      });

      expect(mergeRequest.title).toBe('mr');
      expect(mergeRequest.versions).toEqual(versions);
    });
  });

  describe('SET_MERGE_REQUEST_CHANGES', () => {
    it('sets merge request changes', () => {
      mutations.SET_MERGE_REQUEST_CHANGES(localState, {
        projectPath: 'abcproject',
        mergeRequestId: 1,
        changes: {
          diff: 'abc',
        },
      });

      const newMr = localState.projects.abcproject.mergeRequests[1];

      expect(newMr.changes.diff).toBe('abc');
    });
  });

  describe('SET_MERGE_REQUEST_VERSIONS', () => {
    it('sets merge request versions', () => {
      mutations.SET_MERGE_REQUEST_VERSIONS(localState, {
        projectPath: 'abcproject',
        mergeRequestId: 1,
        versions: [{ id: 123 }],
      });

      const newMr = localState.projects.abcproject.mergeRequests[1];

      expect(newMr.versions.length).toBe(1);
      expect(newMr.versions[0].id).toBe(123);
    });
  });
});