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

bar_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: a363fafdc318e02f1a8efa6acb291e9dea77ca8e (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
import { shallowMount } from '@vue/test-utils';
import { GlBarChart } from '@gitlab/ui/dist/charts';
import Bar from '~/monitoring/components/charts/bar.vue';
import { barGraphData } from '../../graph_data';

jest.mock('~/lib/utils/icon_utils', () => ({
  getSvgIconPathContent: jest.fn().mockResolvedValue('mockSvgPathContent'),
}));

describe('Bar component', () => {
  let barChart;
  let store;
  let graphData;

  beforeEach(() => {
    graphData = barGraphData();

    barChart = shallowMount(Bar, {
      propsData: {
        graphData,
      },
      store,
    });
  });

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

  describe('wrapped components', () => {
    describe('GitLab UI bar chart', () => {
      let glbarChart;
      let chartData;

      beforeEach(() => {
        glbarChart = barChart.find(GlBarChart);
        chartData = barChart.vm.chartData[graphData.metrics[0].label];
      });

      it('should display a label on the x axis', () => {
        expect(glbarChart.props('xAxisTitle')).toBe(graphData.xLabel);
      });

      it('should return chartData as array of arrays', () => {
        expect(chartData).toBeInstanceOf(Array);

        chartData.forEach(item => {
          expect(item).toBeInstanceOf(Array);
        });
      });
    });
  });
});