blob: 65c4970bc769c6c00756bc68576b39a3f9ea90d3 (
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
54
55
56
57
58
59
60
61
62
63
64
65
|
import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import mrStatusIcon from '~/vue_merge_request_widget/components/mr_widget_status_icon.vue';
import StatusIcon from '~/vue_merge_request_widget/components/extensions/status_icon.vue';
describe('MR widget status icon component', () => {
let wrapper;
const findStatusIcon = () => wrapper.findComponent(StatusIcon);
const findIcon = () => wrapper.findComponent(GlIcon);
const createWrapper = (props) => {
wrapper = shallowMount(mrStatusIcon, {
propsData: {
...props,
},
});
};
describe('while loading', () => {
it('renders loading icon', () => {
createWrapper({ status: 'loading' });
expect(findStatusIcon().exists()).toBe(true);
expect(findStatusIcon().props().isLoading).toBe(true);
});
});
describe('with status icon', () => {
it('renders success status icon', () => {
createWrapper({ status: 'success' });
expect(findStatusIcon().exists()).toBe(true);
expect(findStatusIcon().props().iconName).toBe('success');
});
it('renders failed status icon', () => {
createWrapper({ status: 'failed' });
expect(findStatusIcon().exists()).toBe(true);
expect(findStatusIcon().props().iconName).toBe('failed');
});
it('renders merged status icon', () => {
createWrapper({ status: 'merged' });
expect(findIcon().exists()).toBe(true);
expect(findIcon().props().name).toBe('merge');
});
it('renders closed status icon', () => {
createWrapper({ status: 'closed' });
expect(findIcon().exists()).toBe(true);
expect(findIcon().props().name).toBe('merge-request-close');
});
it('renders empty status icon', () => {
createWrapper({ status: 'empty' });
expect(findStatusIcon().exists()).toBe(true);
expect(findStatusIcon().props().iconName).toBe('neutral');
});
});
});
|