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

mutations_spec.js « stores « test_reports « pipelines « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9eaa563025dffa452babe6330abc1945c5890f4b (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
import { getJSONFixture } from 'helpers/fixtures';
import * as types from '~/pipelines/stores/test_reports/mutation_types';
import mutations from '~/pipelines/stores/test_reports/mutations';

describe('Mutations TestReports Store', () => {
  let mockState;

  const testReports = getJSONFixture('pipelines/test_report.json');

  const defaultState = {
    endpoint: '',
    testReports: {},
    selectedSuite: {},
    isLoading: false,
  };

  beforeEach(() => {
    mockState = defaultState;
  });

  describe('set endpoint', () => {
    it('should set endpoint', () => {
      const expectedState = Object.assign({}, mockState, { endpoint: 'foo' });
      mutations[types.SET_ENDPOINT](mockState, 'foo');

      expect(mockState.endpoint).toEqual(expectedState.endpoint);
    });
  });

  describe('set reports', () => {
    it('should set testReports', () => {
      const expectedState = { ...mockState, testReports };
      mutations[types.SET_REPORTS](mockState, testReports);

      expect(mockState.testReports).toEqual(expectedState.testReports);
    });
  });

  describe('set selected suite', () => {
    it('should set selectedSuite', () => {
      const selectedSuite = testReports.test_suites[0];
      mutations[types.SET_SELECTED_SUITE](mockState, selectedSuite);

      expect(mockState.selectedSuite).toEqual(selectedSuite);
    });
  });

  describe('toggle loading', () => {
    it('should set to true', () => {
      const expectedState = Object.assign({}, mockState, { isLoading: true });
      mutations[types.TOGGLE_LOADING](mockState);

      expect(mockState.isLoading).toEqual(expectedState.isLoading);
    });

    it('should toggle back to false', () => {
      const expectedState = Object.assign({}, mockState, { isLoading: false });
      mockState.isLoading = true;

      mutations[types.TOGGLE_LOADING](mockState);

      expect(mockState.isLoading).toEqual(expectedState.isLoading);
    });
  });
});