blob: 5cc1ee049f4c00929572ec1496c1f9d7957c05e6 (
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
|
import { shallowMount, mount } from '@vue/test-utils';
import RunnerEditButton from '~/ci/runner/components/runner_edit_button.vue';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
describe('RunnerEditButton', () => {
let wrapper;
const getTooltipValue = () => getBinding(wrapper.element, 'gl-tooltip').value;
const createComponent = ({ attrs = {}, mountFn = shallowMount } = {}) => {
wrapper = mountFn(RunnerEditButton, {
attrs,
directives: {
GlTooltip: createMockDirective('gl-tooltip'),
},
});
};
beforeEach(() => {
createComponent();
});
it('Displays Edit text', () => {
expect(wrapper.attributes('aria-label')).toBe('Edit');
});
it('Displays Edit tooltip', () => {
expect(getTooltipValue()).toBe('Edit');
});
it('Renders a link and adds an href attribute', () => {
createComponent({ attrs: { href: '/edit' }, mountFn: mount });
expect(wrapper.element.tagName).toBe('A');
expect(wrapper.attributes('href')).toBe('/edit');
});
});
|