summaryrefslogtreecommitdiff
path: root/spec/javascripts/serverless/store/getters_spec.js
blob: fb549c8f153fcfa1611e1052b2e2a687b56b0485 (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 serverlessState from '~/serverless/store/state';
import * as getters from '~/serverless/store/getters';
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;

      const funcs = getters.getFunctions(state);

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