blob: d1bee0c0a16b5384e3728ec1b2ae168bc8124ffc (
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
|
import { shallowMount } from '@vue/test-utils';
import { GlSingleStat } from '@gitlab/ui/dist/charts';
import WorkloadStats from '~/kubernetes_dashboard/components/workload_stats.vue';
import { mockPodStats } from '../graphql/mock_data';
let wrapper;
const createWrapper = () => {
wrapper = shallowMount(WorkloadStats, {
propsData: {
stats: mockPodStats,
},
});
};
const findAllStats = () => wrapper.findAllComponents(GlSingleStat);
const findSingleStat = (at) => findAllStats().at(at);
describe('Workload stats component', () => {
it('renders GlSingleStat component for each stat', () => {
createWrapper();
expect(findAllStats()).toHaveLength(4);
});
it.each`
count | title | index
${2} | ${'Running'} | ${0}
${1} | ${'Pending'} | ${1}
${1} | ${'Succeeded'} | ${2}
${2} | ${'Failed'} | ${3}
`(
'renders stat with title "$title" and count "$count" at index $index',
({ count, title, index }) => {
createWrapper();
expect(findSingleStat(index).props()).toMatchObject({
value: count,
title,
});
},
);
});
|