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

mutations_spec.js « store « accessibility_report « reports « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b336261d8041023d6bfef9078940a60c643cc929 (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
import createStore from '~/reports/accessibility_report/store';
import mutations from '~/reports/accessibility_report/store/mutations';

describe('Accessibility Reports mutations', () => {
  let localState;
  let localStore;

  beforeEach(() => {
    localStore = createStore();
    localState = localStore.state;
  });

  describe('SET_ENDPOINT', () => {
    it('sets endpoint to given value', () => {
      const endpoint = 'endpoint.json';
      mutations.SET_ENDPOINT(localState, endpoint);

      expect(localState.endpoint).toEqual(endpoint);
    });
  });

  describe('REQUEST_REPORT', () => {
    it('sets isLoading to true', () => {
      mutations.REQUEST_REPORT(localState);

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

  describe('RECEIVE_REPORT_SUCCESS', () => {
    it('sets isLoading to false', () => {
      mutations.RECEIVE_REPORT_SUCCESS(localState, {});

      expect(localState.isLoading).toEqual(false);
    });

    it('sets hasError to false', () => {
      mutations.RECEIVE_REPORT_SUCCESS(localState, {});

      expect(localState.hasError).toEqual(false);
    });

    it('sets report to response report', () => {
      const report = { data: 'testing' };
      mutations.RECEIVE_REPORT_SUCCESS(localState, report);

      expect(localState.report).toEqual(report);
    });
  });

  describe('RECEIVE_REPORT_ERROR', () => {
    it('sets isLoading to false', () => {
      mutations.RECEIVE_REPORT_ERROR(localState);

      expect(localState.isLoading).toEqual(false);
    });

    it('sets hasError to true', () => {
      mutations.RECEIVE_REPORT_ERROR(localState);

      expect(localState.hasError).toEqual(true);
    });
  });
});