1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import { mount } from '@vue/test-utils';
import PipelinesTable from '~/pipelines/components/pipelines_list/pipelines_table.vue';
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);
});
});
});
|