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

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

describe('Artifacts Store Mutations', () => {
  let stateCopy;

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

  describe('SET_ENDPOINT', () => {
    it('should set endpoint', () => {
      mutations[types.SET_ENDPOINT](stateCopy, 'endpoint.json');

      expect(stateCopy.endpoint).toEqual('endpoint.json');
    });
  });

  describe('REQUEST_ARTIFACTS', () => {
    it('should set isLoading to true', () => {
      mutations[types.REQUEST_ARTIFACTS](stateCopy);

      expect(stateCopy.isLoading).toEqual(true);
    });
  });

  describe('REECEIVE_ARTIFACTS_SUCCESS', () => {
    const artifacts = [
      {
        text: 'result.txt',
        url: 'asda',
        job_name: 'generate-artifact',
        job_path: 'asda',
      },
      {
        text: 'file.txt',
        url: 'asda',
        job_name: 'generate-artifact',
        job_path: 'asda',
      },
    ];

    beforeEach(() => {
      mutations[types.RECEIVE_ARTIFACTS_SUCCESS](stateCopy, artifacts);
    });

    it('should set isLoading to false', () => {
      expect(stateCopy.isLoading).toEqual(false);
    });

    it('should set hasError to false', () => {
      expect(stateCopy.hasError).toEqual(false);
    });

    it('should set list of artifacts', () => {
      expect(stateCopy.artifacts).toEqual(artifacts);
    });
  });

  describe('RECEIVE_ARTIFACTS_ERROR', () => {
    beforeEach(() => {
      mutations[types.RECEIVE_ARTIFACTS_ERROR](stateCopy);
    });

    it('should set isLoading to false', () => {
      expect(stateCopy.isLoading).toEqual(false);
    });

    it('should set hasError to true', () => {
      expect(stateCopy.hasError).toEqual(true);
    });

    it('should set list of artifacts as empty array', () => {
      expect(stateCopy.artifacts).toEqual([]);
    });
  });
});