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

memory_graph_spec.js « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ae8d5ff78ba03135be943227aaee1e056dfdf404 (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 { GlSparklineChart } from '@gitlab/ui/dist/charts';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import MemoryGraph from '~/vue_shared/components/memory_graph.vue';

describe('MemoryGraph', () => {
  const Component = Vue.extend(MemoryGraph);
  let wrapper;
  const metrics = [
    [1573586253.853, '2.87'],
    [1573586313.853, '2.77734375'],
    [1573586373.853, '2.77734375'],
    [1573586433.853, '3.0066964285714284'],
  ];

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

  beforeEach(() => {
    wrapper = shallowMount(Component, {
      propsData: {
        metrics,
        width: 100,
        height: 25,
      },
    });
  });

  describe('chartData', () => {
    it('should calculate chartData', () => {
      expect(wrapper.vm.chartData.length).toEqual(metrics.length);
    });

    it('should format date & MB values', () => {
      const formattedData = [
        ['Nov 12 2019 19:17:33', '2.87'],
        ['Nov 12 2019 19:18:33', '2.78'],
        ['Nov 12 2019 19:19:33', '2.78'],
        ['Nov 12 2019 19:20:33', '3.01'],
      ];
      expect(wrapper.vm.chartData).toEqual(formattedData);
    });
  });

  describe('Render chart', () => {
    it('should draw container with chart', () => {
      expect(wrapper.element).toMatchSnapshot();
      expect(wrapper.find('.memory-graph-container').exists()).toBe(true);
      expect(wrapper.findComponent(GlSparklineChart).exists()).toBe(true);
    });
  });
});