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
94
95
96
97
98
99
|
import { GlBadge, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ImportStatus from '~/import_entities/import_groups/components/import_status.vue';
import { STATUSES, STATUS_ICON_MAP } from '~/import_entities/constants';
describe('Group import status component', () => {
let wrapper;
const defaultProps = {
status: STATUSES.FINISHED,
};
const mockDetailsPath = '/details';
const createComponent = ({ props } = {}) => {
wrapper = shallowMount(ImportStatus, {
propsData: {
...defaultProps,
...props,
},
provide: {
detailsPath: mockDetailsPath,
},
});
};
const findGlBadge = () => wrapper.findComponent(GlBadge);
const findGlLink = () => wrapper.findComponent(GlLink);
describe('status badge text', () => {
describe('when import is partial', () => {
beforeEach(() => {
createComponent({
props: {
status: STATUSES.FINISHED,
hasFailures: true,
},
});
});
it('renders warning badge with text', () => {
expect(findGlBadge().props()).toMatchObject({
icon: 'status-alert',
variant: 'warning',
});
expect(findGlBadge().text()).toBe('Partially completed');
});
});
describe.each([
STATUSES.CREATED,
STATUSES.FAILED,
STATUSES.FINISHED,
STATUSES.STARTED,
STATUSES.TIMEOUT,
])(`when import is %s`, (status) => {
beforeEach(() => {
createComponent({
props: {
status,
},
});
});
it('renders badge with text', () => {
const expectedStatus = STATUS_ICON_MAP[status];
expect(findGlBadge().props()).toMatchObject({
icon: expectedStatus.icon,
variant: expectedStatus.variant,
});
expect(findGlBadge().text()).toBe(expectedStatus.text);
});
});
});
describe('details link', () => {
it('does not render by default', () => {
createComponent();
expect(findGlLink().exists()).toBe(false);
});
it('renders with correct link when import is partial', () => {
createComponent({
props: {
id: 2,
entityId: 11,
hasFailures: true,
showDetailsLink: true,
status: STATUSES.FINISHED,
},
});
expect(findGlLink().attributes('href')).toBe('/details?id=2&entity_id=11');
});
});
});
|