2019-12-04 20:38:33 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { nextTick } from 'vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import DurationBadge from '~/jobs/components/log/duration_badge.vue';
|
2019-12-04 20:38:33 +05:30
|
|
|
import LineHeader from '~/jobs/components/log/line_header.vue';
|
|
|
|
import LineNumber from '~/jobs/components/log/line_number.vue';
|
|
|
|
|
|
|
|
describe('Job Log Header Line', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
line: {
|
|
|
|
content: [
|
|
|
|
{
|
|
|
|
text: 'Running with gitlab-runner 12.1.0 (de7731dd)',
|
|
|
|
style: 'term-fg-l-green',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
lineNumber: 0,
|
|
|
|
},
|
|
|
|
isClosed: true,
|
|
|
|
path: '/jashkenas/underscore/-/jobs/335',
|
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = (props = {}) => {
|
|
|
|
wrapper = mount(LineHeader, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('line', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the line number component', () => {
|
2022-10-11 01:57:18 +05:30
|
|
|
expect(wrapper.findComponent(LineNumber).exists()).toBe(true);
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders a span the provided text', () => {
|
|
|
|
expect(wrapper.find('span').text()).toBe(data.line.content[0].text);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the provided style as a class attribute', () => {
|
|
|
|
expect(wrapper.find('span').classes()).toContain(data.line.content[0].style);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when isCloses is true', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ ...data, isClosed: true });
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
it('sets icon name to be chevron-lg-right', () => {
|
|
|
|
expect(wrapper.vm.iconName).toEqual('chevron-lg-right');
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when isCloses is false', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ ...data, isClosed: false });
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
it('sets icon name to be chevron-lg-down', () => {
|
|
|
|
expect(wrapper.vm.iconName).toEqual('chevron-lg-down');
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('on click', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent(data);
|
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('emits toggleLine event', async () => {
|
2019-12-04 20:38:33 +05:30
|
|
|
wrapper.trigger('click');
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
await nextTick();
|
|
|
|
expect(wrapper.emitted().toggleLine.length).toBe(1);
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with duration', () => {
|
|
|
|
beforeEach(() => {
|
2020-05-24 23:13:21 +05:30
|
|
|
createComponent({ ...data, duration: '00:10' });
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the duration badge', () => {
|
2022-10-11 01:57:18 +05:30
|
|
|
expect(wrapper.findComponent(DurationBadge).exists()).toBe(true);
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|