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
|
import { GlIcon, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { s__ } from '~/locale';
import PipelineScheduleTarget from '~/ci/pipeline_schedules/components/table/cells/pipeline_schedule_target.vue';
import { mockPipelineScheduleNodes } from '../../../mock_data';
describe('Pipeline schedule target', () => {
let wrapper;
const defaultProps = {
schedule: mockPipelineScheduleNodes[0],
};
const createComponent = (props = defaultProps) => {
wrapper = shallowMount(PipelineScheduleTarget, {
propsData: {
...props,
},
});
};
const findIcon = () => wrapper.findComponent(GlIcon);
const findLink = () => wrapper.findComponent(GlLink);
const findTarget = () => wrapper.findComponent('[data-testid="pipeline-schedule-target"]');
describe('with ref', () => {
beforeEach(() => {
createComponent();
});
it('displays icon', () => {
expect(findIcon().exists()).toBe(true);
expect(findIcon().props('name')).toBe('fork');
});
it('displays ref link', () => {
expect(findLink().attributes('href')).toBe(defaultProps.schedule.refPath);
expect(findLink().text()).toBe(defaultProps.schedule.refForDisplay);
});
});
describe('without refPath', () => {
beforeEach(() => {
createComponent({
schedule: { ...mockPipelineScheduleNodes[0], refPath: null, refForDisplay: null },
});
});
it('displays none for the target', () => {
expect(findIcon().exists()).toBe(false);
expect(findLink().exists()).toBe(false);
expect(findTarget().text()).toBe(s__('PipelineSchedules|None'));
});
});
});
|