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
70
71
|
import { shallowMount } from '@vue/test-utils';
import SingleStatChart from '~/monitoring/components/charts/single_stat.vue';
import { singleStatMetricsResult } from '../../mock_data';
describe('Single Stat Chart component', () => {
let singleStatChart;
beforeEach(() => {
singleStatChart = shallowMount(SingleStatChart, {
propsData: {
graphData: singleStatMetricsResult,
},
});
});
afterEach(() => {
singleStatChart.destroy();
});
describe('computed', () => {
describe('statValue', () => {
it('should interpolate the value and unit props', () => {
expect(singleStatChart.vm.statValue).toBe('91.00MB');
});
it('should change the value representation to a percentile one', () => {
singleStatChart.setProps({
graphData: {
...singleStatMetricsResult,
maxValue: 120,
},
});
expect(singleStatChart.vm.statValue).toContain('75.83%');
});
it('should display NaN for non numeric maxValue values', () => {
singleStatChart.setProps({
graphData: {
...singleStatMetricsResult,
maxValue: 'not a number',
},
});
expect(singleStatChart.vm.statValue).toContain('NaN');
});
it('should display NaN for missing query values', () => {
singleStatChart.setProps({
graphData: {
...singleStatMetricsResult,
metrics: [
{
...singleStatMetricsResult.metrics[0],
result: [
{
...singleStatMetricsResult.metrics[0].result[0],
value: [''],
},
],
},
],
maxValue: 120,
},
});
expect(singleStatChart.vm.statValue).toContain('NaN');
});
});
});
});
|