debian-mirror-gitlab/spec/frontend/jobs/components/log/line_header_spec.js

97 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-12-04 20:38:33 +05:30
import { mount } from '@vue/test-utils';
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', () => {
2020-11-24 15:15:51 +05:30
expect(wrapper.find(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 });
});
it('sets icon name to be angle-right', () => {
expect(wrapper.vm.iconName).toEqual('angle-right');
});
});
describe('when isCloses is false', () => {
beforeEach(() => {
createComponent({ ...data, isClosed: false });
});
it('sets icon name to be angle-down', () => {
expect(wrapper.vm.iconName).toEqual('angle-down');
});
});
describe('on click', () => {
beforeEach(() => {
createComponent(data);
});
it('emits toggleLine event', () => {
wrapper.trigger('click');
2020-03-13 15:44:24 +05:30
return wrapper.vm.$nextTick().then(() => {
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', () => {
2020-11-24 15:15:51 +05:30
expect(wrapper.find(DurationBadge).exists()).toBe(true);
2019-12-04 20:38:33 +05:30
});
});
});