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

getters_spec.js « store « serverless « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1942bd275974a2dc5cb3364f8d80be99a42e052 (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
import * as getters from '~/serverless/store/getters';
import serverlessState from '~/serverless/store/state';
import { mockServerlessFunctions } from '../mock_data';

describe('Serverless Store Getters', () => {
  let state;

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

  describe('hasPrometheusMissingData', () => {
    it('should return false if Prometheus is not installed', () => {
      state.hasPrometheus = false;

      expect(getters.hasPrometheusMissingData(state)).toEqual(false);
    });

    it('should return false if Prometheus is installed and there is data', () => {
      state.hasPrometheusData = true;

      expect(getters.hasPrometheusMissingData(state)).toEqual(false);
    });

    it('should return true if Prometheus is installed and there is no data', () => {
      state.hasPrometheus = true;
      state.hasPrometheusData = false;

      expect(getters.hasPrometheusMissingData(state)).toEqual(true);
    });
  });

  describe('getFunctions', () => {
    it('should translate the raw function array to group the functions per environment scope', () => {
      state.functions = mockServerlessFunctions.functions;

      const funcs = getters.getFunctions(state);

      expect(Object.keys(funcs)).toContain('*');
      expect(funcs['*'].length).toEqual(2);
    });
  });
});