blob: 3c8821d05a7b917374e75ae4edaf073375709462 (
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
|
import { getByRole } from '@testing-library/dom';
import { mount } from '@vue/test-utils';
import PipelineConfigReferenceCard from '~/pipeline_editor/components/drawer/cards/pipeline_config_reference_card.vue';
describe('Pipeline config reference card', () => {
let wrapper;
const defaultProvide = {
ciExamplesHelpPagePath: 'help/ci/examples/',
ciHelpPagePath: 'help/ci/introduction',
needsHelpPagePath: 'help/ci/yaml#needs',
ymlHelpPagePath: 'help/ci/yaml',
};
const createComponent = () => {
wrapper = mount(PipelineConfigReferenceCard, {
provide: {
...defaultProvide,
},
});
};
const getLinkByName = (name) => getByRole(wrapper.element, 'link', { name }).href;
const findCiExamplesLink = () => getLinkByName(/CI\/CD examples and templates/i);
const findCiIntroLink = () => getLinkByName(/GitLab CI\/CD concepts/i);
const findNeedsLink = () => getLinkByName(/Needs keyword/i);
const findYmlSyntaxLink = () => getLinkByName(/.gitlab-ci.yml syntax reference/i);
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders the title', () => {
expect(wrapper.text()).toContain(wrapper.vm.$options.i18n.title);
});
it('renders the content', () => {
expect(wrapper.text()).toContain(wrapper.vm.$options.i18n.firstParagraph);
});
it('renders the links', () => {
expect(findCiExamplesLink()).toContain(defaultProvide.ciExamplesHelpPagePath);
expect(findCiIntroLink()).toContain(defaultProvide.ciHelpPagePath);
expect(findNeedsLink()).toContain(defaultProvide.needsHelpPagePath);
expect(findYmlSyntaxLink()).toContain(defaultProvide.ymlHelpPagePath);
});
});
|