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
86
87
88
89
90
91
92
93
|
import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
describe('CI Icon component', () => {
let wrapper;
const createComponent = (props) => {
wrapper = shallowMount(CiIcon, {
propsData: {
...props,
},
});
};
it('should render a span element with an svg', () => {
createComponent({
status: {
group: 'success',
icon: 'status_success',
},
});
expect(wrapper.find('span').exists()).toBe(true);
expect(wrapper.findComponent(GlIcon).exists()).toBe(true);
});
describe.each`
isActive
${true}
${false}
`('when isActive is $isActive', ({ isActive }) => {
it(`"active" class is ${isActive ? 'not ' : ''}added`, () => {
wrapper = shallowMount(CiIcon, {
propsData: {
status: {
group: 'success',
icon: 'status_success',
},
isActive,
},
});
expect(wrapper.classes('active')).toBe(isActive);
});
});
describe.each`
isInteractive
${true}
${false}
`('when isInteractive is $isInteractive', ({ isInteractive }) => {
it(`"interactive" class is ${isInteractive ? 'not ' : ''}added`, () => {
wrapper = shallowMount(CiIcon, {
propsData: {
status: {
group: 'success',
icon: 'status_success',
},
isInteractive,
},
});
expect(wrapper.classes('interactive')).toBe(isInteractive);
});
});
describe('rendering a status', () => {
it.each`
icon | group | cssClass
${'status_success'} | ${'success'} | ${'ci-status-icon-success'}
${'status_failed'} | ${'failed'} | ${'ci-status-icon-failed'}
${'status_warning'} | ${'warning'} | ${'ci-status-icon-warning'}
${'status_pending'} | ${'pending'} | ${'ci-status-icon-pending'}
${'status_running'} | ${'running'} | ${'ci-status-icon-running'}
${'status_created'} | ${'created'} | ${'ci-status-icon-created'}
${'status_skipped'} | ${'skipped'} | ${'ci-status-icon-skipped'}
${'status_canceled'} | ${'canceled'} | ${'ci-status-icon-canceled'}
${'status_manual'} | ${'manual'} | ${'ci-status-icon-manual'}
`('should render a $group status', ({ icon, group, cssClass }) => {
wrapper = shallowMount(CiIcon, {
propsData: {
status: {
icon,
group,
},
},
});
expect(wrapper.classes()).toContain(cssClass);
});
});
});
|