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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
import { shallowMount } from '@vue/test-utils';
import GraphBar from '~/branches/components/graph_bar.vue';
let vm;
function factory(propsData = {}) {
vm = shallowMount(GraphBar, { propsData });
}
describe('Branch divergence graph bar component', () => {
it.each`
position | positionClass
${'left'} | ${'position-right-0'}
${'right'} | ${'position-left-0'}
${'full'} | ${'position-left-0'}
`(
'sets position class as $positionClass for position $position',
({ position, positionClass }) => {
factory({
position,
count: 10,
maxCommits: 100,
});
expect(vm.find('.js-graph-bar').classes()).toContain(positionClass);
},
);
it.each`
position | textAlignmentClass
${'left'} | ${'text-right'}
${'right'} | ${'text-left'}
${'full'} | ${'text-center'}
`(
'sets text alignment class as $textAlignmentClass for position $position',
({ position, textAlignmentClass }) => {
factory({
position,
count: 10,
maxCommits: 100,
});
expect(vm.find('.js-graph-count').classes()).toContain(textAlignmentClass);
},
);
it.each`
position | roundedClass
${'left'} | ${'rounded-left'}
${'right'} | ${'rounded-right'}
${'full'} | ${'rounded'}
`('sets rounded class as $roundedClass for position $position', ({ position, roundedClass }) => {
factory({
position,
count: 10,
maxCommits: 100,
});
expect(vm.find('.js-graph-bar').classes()).toContain(roundedClass);
});
it.each`
count | label
${100} | ${'100'}
${1000} | ${'999+'}
`('renders label as $roundedClass for $count', ({ count, label }) => {
factory({
position: 'left',
count,
maxCommits: 1000,
});
expect(vm.find('.js-graph-count').text()).toContain(label);
});
it('sets width of bar', () => {
factory({
position: 'left',
count: 100,
maxCommits: 1000,
});
expect(vm.find('.js-graph-bar').attributes('style')).toEqual('width: 10%;');
});
});
|