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
|
import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import RunnerSummaryField from '~/ci/runner/components/cells/runner_summary_field.vue';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
describe('RunnerSummaryField', () => {
let wrapper;
const findIcon = () => wrapper.findComponent(GlIcon);
const getTooltipValue = () => getBinding(wrapper.element, 'gl-tooltip').value;
const createComponent = ({ props, ...options } = {}) => {
wrapper = shallowMount(RunnerSummaryField, {
propsData: {
icon: '',
tooltip: '',
...props,
},
directives: {
GlTooltip: createMockDirective('gl-tooltip'),
},
...options,
});
};
it('shows content in slot', () => {
createComponent({
slots: { default: 'content' },
});
expect(wrapper.text()).toBe('content');
});
it('shows icon', () => {
createComponent({ props: { icon: 'git' } });
expect(findIcon().props('name')).toBe('git');
});
it('shows tooltip', () => {
createComponent({ props: { tooltip: 'tooltip' } });
expect(getTooltipValue()).toBe('tooltip');
});
});
|