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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import { mount } from '@vue/test-utils';
import Vue from 'vue';
2019-12-04 20:38:33 +05:30
import Vuex from 'vuex';
import Log from '~/jobs/components/log/log.vue';
2022-08-13 15:12:31 +05:30
import { logLinesParser } from '~/jobs/store/utils';
2019-12-04 20:38:33 +05:30
import { jobLog } from './mock_data';
describe('Job Log', () => {
let wrapper;
let actions;
let state;
let store;
2022-04-04 11:22:00 +05:30
Vue.use(Vuex);
2019-12-04 20:38:33 +05:30
const createComponent = () => {
wrapper = mount(Log, {
store,
});
};
beforeEach(() => {
actions = {
toggleCollapsibleLine: () => {},
};
state = {
2022-08-13 15:12:31 +05:30
jobLog: logLinesParser(jobLog),
2021-11-18 22:05:49 +05:30
jobLogEndpoint: 'jobs/id',
2019-12-04 20:38:33 +05:30
};
store = new Vuex.Store({
actions,
state,
});
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
2020-11-24 15:15:51 +05:30
const findCollapsibleLine = () => wrapper.find('.collapsible-line');
2019-12-04 20:38:33 +05:30
describe('line numbers', () => {
it('renders a line number for each open line', () => {
expect(wrapper.find('#L1').text()).toBe('1');
expect(wrapper.find('#L2').text()).toBe('2');
expect(wrapper.find('#L3').text()).toBe('3');
});
it('links to the provided path and correct line number', () => {
2021-11-18 22:05:49 +05:30
expect(wrapper.find('#L1').attributes('href')).toBe(`${state.jobLogEndpoint}#L1`);
2019-12-04 20:38:33 +05:30
});
});
describe('collapsible sections', () => {
it('renders a clickable header section', () => {
2020-11-24 15:15:51 +05:30
expect(findCollapsibleLine().attributes('role')).toBe('button');
2019-12-04 20:38:33 +05:30
});
2019-12-26 22:10:19 +05:30
it('renders an icon with the open state', () => {
2022-07-23 23:45:48 +05:30
expect(findCollapsibleLine().find('[data-testid="chevron-lg-down-icon"]').exists()).toBe(
true,
);
2019-12-04 20:38:33 +05:30
});
describe('on click header section', () => {
it('calls toggleCollapsibleLine', () => {
jest.spyOn(wrapper.vm, 'toggleCollapsibleLine');
2020-11-24 15:15:51 +05:30
findCollapsibleLine().trigger('click');
2019-12-04 20:38:33 +05:30
expect(wrapper.vm.toggleCollapsibleLine).toHaveBeenCalled();
});
});
});
});