debian-mirror-gitlab/spec/frontend/jobs/components/sidebar_detail_row_spec.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import SidebarDetailRow from '~/jobs/components/sidebar_detail_row.vue';
2017-09-10 17:25:29 +05:30
describe('Sidebar detail row', () => {
2021-03-11 19:13:27 +05:30
let wrapper;
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
const title = 'this is the title';
const value = 'this is the value';
2021-09-30 23:02:18 +05:30
const helpUrl = '/help/ci/runners/index.html';
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
const findHelpLink = () => wrapper.findComponent(GlLink);
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
const createComponent = (props) => {
wrapper = shallowMount(SidebarDetailRow, {
2017-09-10 17:25:29 +05:30
propsData: {
2021-03-11 19:13:27 +05:30
...props,
2017-09-10 17:25:29 +05:30
},
2021-03-11 19:13:27 +05:30
});
};
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
afterEach(() => {
wrapper.destroy();
wrapper = null;
2017-09-10 17:25:29 +05:30
});
2021-03-11 19:13:27 +05:30
describe('with title/value and without helpUrl', () => {
beforeEach(() => {
createComponent({ title, value });
});
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
it('should render the provided title and value', () => {
expect(wrapper.text()).toBe(`${title}: ${value}`);
});
2018-05-09 12:01:36 +05:30
2021-03-11 19:13:27 +05:30
it('should not render the help link', () => {
expect(findHelpLink().exists()).toBe(false);
2018-05-09 12:01:36 +05:30
});
});
describe('when helpUrl provided', () => {
beforeEach(() => {
2021-03-11 19:13:27 +05:30
createComponent({
helpUrl,
title,
value,
});
2018-05-09 12:01:36 +05:30
});
2021-03-11 19:13:27 +05:30
it('should render the help link', () => {
expect(findHelpLink().exists()).toBe(true);
expect(findHelpLink().attributes('href')).toBe(helpUrl);
2018-05-09 12:01:36 +05:30
});
});
2017-09-10 17:25:29 +05:30
});