summaryrefslogtreecommitdiff
path: root/spec/frontend/monitoring/components/charts/column_spec.js
blob: b4539801e0f72f922c3fb2752014c2b847f306a7 (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
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { GlColumnChart } from '@gitlab/ui/dist/charts';
import ColumnChart from '~/monitoring/components/charts/column.vue';

const localVue = createLocalVue();

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

describe('Column component', () => {
  let columnChart;

  beforeEach(() => {
    columnChart = shallowMount(localVue.extend(ColumnChart), {
      propsData: {
        graphData: {
          metrics: [
            {
              x_label: 'Time',
              y_label: 'Usage',
              result: [
                {
                  metric: {},
                  values: [
                    [1495700554.925, '8.0390625'],
                    [1495700614.925, '8.0390625'],
                    [1495700674.925, '8.0390625'],
                  ],
                },
              ],
            },
          ],
        },
        containerWidth: 100,
      },
      sync: false,
      localVue,
    });
  });

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

  describe('wrapped components', () => {
    describe('GitLab UI column chart', () => {
      let glColumnChart;

      beforeEach(() => {
        glColumnChart = columnChart.find(GlColumnChart);
      });

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

      it('receives data properties needed for proper chart render', () => {
        const props = glColumnChart.props();

        expect(props.data).toBe(columnChart.vm.chartData);
        expect(props.option).toBe(columnChart.vm.chartOptions);
      });
    });
  });
});