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

heatmap_spec.js « charts « components « monitoring « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e2c1932e9e472f7184e537fc67b9253ca2e31b9 (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
import { shallowMount } from '@vue/test-utils';
import { GlHeatmap } from '@gitlab/ui/dist/charts';
import Heatmap from '~/monitoring/components/charts/heatmap.vue';
import { graphDataPrometheusQueryRangeMultiTrack } from '../../mock_data';

describe('Heatmap component', () => {
  let heatmapChart;
  let store;

  beforeEach(() => {
    heatmapChart = shallowMount(Heatmap, {
      propsData: {
        graphData: graphDataPrometheusQueryRangeMultiTrack,
        containerWidth: 100,
      },
      store,
    });
  });

  afterEach(() => {
    heatmapChart.destroy();
  });

  describe('wrapped components', () => {
    describe('GitLab UI heatmap chart', () => {
      let glHeatmapChart;

      beforeEach(() => {
        glHeatmapChart = heatmapChart.find(GlHeatmap);
      });

      it('is a Vue instance', () => {
        expect(glHeatmapChart.isVueInstance()).toBe(true);
      });

      it('should display a label on the x axis', () => {
        expect(heatmapChart.vm.xAxisName).toBe(graphDataPrometheusQueryRangeMultiTrack.x_label);
      });

      it('should display a label on the y axis', () => {
        expect(heatmapChart.vm.yAxisName).toBe(graphDataPrometheusQueryRangeMultiTrack.y_label);
      });

      // According to the echarts docs https://echarts.apache.org/en/option.html#series-heatmap.data
      // each row of the heatmap chart is represented by an array inside another parent array
      // e.g. [[0, 0, 10]], the format represents the column, the row and finally the value
      // corresponding to the cell

      it('should return chartData with a length of x by y, with a length of 3 per array', () => {
        const row = heatmapChart.vm.chartData[0];

        expect(row.length).toBe(3);
        expect(heatmapChart.vm.chartData.length).toBe(30);
      });

      it('returns a series of labels for the x axis', () => {
        const { xAxisLabels } = heatmapChart.vm;

        expect(xAxisLabels.length).toBe(5);
      });

      it('returns a series of labels for the y axis', () => {
        const { yAxisLabels } = heatmapChart.vm;

        expect(yAxisLabels.length).toBe(6);
      });
    });
  });
});