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

getters_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: d74c71cfa09e90602c40de23e01ec79bcb891852 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import * as getters from '~/reports/accessibility_report/store/getters';
import createStore from '~/reports/accessibility_report/store';
import { LOADING, ERROR, SUCCESS, STATUS_FAILED } from '~/reports/constants';

describe('Accessibility reports store getters', () => {
  let localState;
  let localStore;

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

  describe('summaryStatus', () => {
    describe('when summary is loading', () => {
      it('returns loading status', () => {
        localState.isLoading = true;

        expect(getters.summaryStatus(localState)).toEqual(LOADING);
      });
    });

    describe('when summary has error', () => {
      it('returns error status', () => {
        localState.hasError = true;

        expect(getters.summaryStatus(localState)).toEqual(ERROR);
      });
    });

    describe('when summary has failed status', () => {
      it('returns loading status', () => {
        localState.status = STATUS_FAILED;

        expect(getters.summaryStatus(localState)).toEqual(ERROR);
      });
    });

    describe('when summary has successfully loaded', () => {
      it('returns loading status', () => {
        expect(getters.summaryStatus(localState)).toEqual(SUCCESS);
      });
    });
  });

  describe('groupedSummaryText', () => {
    describe('when state is loading', () => {
      it('returns the loading summary message', () => {
        localState.isLoading = true;
        const result = 'Accessibility scanning results are being parsed';

        expect(getters.groupedSummaryText(localState)).toEqual(result);
      });
    });

    describe('when state has error', () => {
      it('returns the error summary message', () => {
        localState.hasError = true;
        const result = 'Accessibility scanning failed loading results';

        expect(getters.groupedSummaryText(localState)).toEqual(result);
      });
    });

    describe('when state has successfully loaded', () => {
      describe('when report has errors', () => {
        it('returns summary message containing number of errors', () => {
          localState.report = {
            summary: {
              errored: 2,
            },
          };
          const result = 'Accessibility scanning detected 2 issues for the source branch only';

          expect(getters.groupedSummaryText(localState)).toEqual(result);
        });
      });

      describe('when report has no errors', () => {
        it('returns summary message containing no errors', () => {
          localState.report = {
            summary: {
              errored: 0,
            },
          };
          const result = 'Accessibility scanning detected no issues for the source branch only';

          expect(getters.groupedSummaryText(localState)).toEqual(result);
        });
      });
    });
  });

  describe('shouldRenderIssuesList', () => {
    describe('when has issues to render', () => {
      it('returns true', () => {
        localState.report = {
          existing_errors: [{ name: 'Issue' }],
        };

        expect(getters.shouldRenderIssuesList(localState)).toEqual(true);
      });
    });

    describe('when does not have issues to render', () => {
      it('returns false', () => {
        localState.report = {
          status: 'success',
          summary: { errored: 0 },
        };

        expect(getters.shouldRenderIssuesList(localState)).toEqual(false);
      });
    });
  });

  describe('unresolvedIssues', () => {
    it('returns the array unresolved errors', () => {
      localState.report = {
        existing_errors: [1],
      };
      const result = [1];

      expect(getters.unresolvedIssues(localState)).toEqual(result);
    });
  });

  describe('resolvedIssues', () => {
    it('returns array of resolved errors', () => {
      localState.report = {
        resolved_errors: [1],
      };
      const result = [1];

      expect(getters.resolvedIssues(localState)).toEqual(result);
    });
  });

  describe('newIssues', () => {
    it('returns array of new errors', () => {
      localState.report = {
        new_errors: [1],
      };
      const result = [1];

      expect(getters.newIssues(localState)).toEqual(result);
    });
  });
});