debian-mirror-gitlab/spec/frontend/pipelines/pipelines_table_spec.js

67 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import { mount } from '@vue/test-utils';
2020-07-28 23:09:34 +05:30
import PipelinesTable from '~/pipelines/components/pipelines_list/pipelines_table.vue';
2020-05-24 23:13:21 +05:30
describe('Pipelines Table', () => {
let pipeline;
let wrapper;
const jsonFixtureName = 'pipelines/pipelines.json';
const defaultProps = {
pipelines: [],
autoDevopsHelpPath: 'foo',
viewType: 'root',
};
const createComponent = (props = defaultProps) => {
wrapper = mount(PipelinesTable, {
propsData: props,
});
};
const findRows = () => wrapper.findAll('.commit.gl-responsive-table-row');
preloadFixtures(jsonFixtureName);
beforeEach(() => {
const { pipelines } = getJSONFixture(jsonFixtureName);
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('table', () => {
it('should render a table', () => {
expect(wrapper.classes()).toContain('ci-table');
});
it('should render table head with correct columns', () => {
expect(wrapper.find('.table-section.js-pipeline-status').text()).toEqual('Status');
expect(wrapper.find('.table-section.js-pipeline-info').text()).toEqual('Pipeline');
expect(wrapper.find('.table-section.js-pipeline-commit').text()).toEqual('Commit');
expect(wrapper.find('.table-section.js-pipeline-stages').text()).toEqual('Stages');
});
});
describe('without data', () => {
it('should render an empty table', () => {
expect(findRows()).toHaveLength(0);
});
});
describe('with data', () => {
it('should render rows', () => {
createComponent({ pipelines: [pipeline], autoDevopsHelpPath: 'foo', viewType: 'root' });
expect(findRows()).toHaveLength(1);
});
});
});