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: b935029bc6a5e30ee21718cd9f67b7dc32f08080 (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
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: null,
    isLoading: false,
  };

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

  describe('set suite', () => {
    it('should set the suite at the given index', () => {
      mockState.testReports = testReports;
      const suite = { name: 'test_suite' };
      const index = 0;
      const expectedState = { ...mockState };
      expectedState.testReports.test_suites[index] = { suite, hasFullSuite: true };
      mutations[types.SET_SUITE](mockState, { suite, index });

      expect(mockState.testReports.test_suites[index]).toEqual(
        expectedState.testReports.test_suites[index],
      );
    });
  });

  describe('set selected suite index', () => {
    it('should set selectedSuiteIndex', () => {
      const selectedSuiteIndex = 0;
      mutations[types.SET_SELECTED_SUITE_INDEX](mockState, selectedSuiteIndex);

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

  describe('set summary', () => {
    it('should set summary', () => {
      const summary = {
        total: { time: 0, count: 10, success: 1, failed: 2, skipped: 3, error: 4 },
      };
      const expectedSummary = {
        ...summary,
        total_time: 0,
        total_count: 10,
        success_count: 1,
        failed_count: 2,
        skipped_count: 3,
        error_count: 4,
      };
      mutations[types.SET_SUMMARY](mockState, summary);

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

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

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

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

      mutations[types.TOGGLE_LOADING](mockState);

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