gitlab-org--gitlab-foss/spec/javascripts/pipelines/pipelines_table_spec.js

87 lines
2.3 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
import pipelinesTableComp from '~/pipelines/components/pipelines_table.vue';
import '~/lib/utils/datetime_utility';
describe('Pipelines Table', () => {
const jsonFixtureName = 'pipelines/pipelines.json';
let pipeline;
let PipelinesTableComponent;
preloadFixtures(jsonFixtureName);
beforeEach(() => {
const { pipelines } = getJSONFixture(jsonFixtureName);
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
});
describe('table', () => {
let component;
beforeEach(() => {
component = new PipelinesTableComponent({
propsData: {
pipelines: [],
autoDevopsHelpPath: 'foo',
2017-10-23 09:36:02 -04:00
viewType: 'root',
},
}).$mount();
});
afterEach(() => {
component.$destroy();
});
it('should render a table', () => {
expect(component.$el.getAttribute('class')).toContain('ci-table');
});
it('should render table head with correct columns', () => {
2018-10-17 03:13:26 -04:00
expect(
component.$el.querySelector('.table-section.js-pipeline-status').textContent.trim(),
).toEqual('Status');
2018-10-17 03:21:28 -04:00
2018-10-17 03:13:26 -04:00
expect(
component.$el.querySelector('.table-section.js-pipeline-info').textContent.trim(),
).toEqual('Pipeline');
2018-10-17 03:21:28 -04:00
2018-10-17 03:13:26 -04:00
expect(
component.$el.querySelector('.table-section.js-pipeline-commit').textContent.trim(),
).toEqual('Commit');
2018-10-17 03:21:28 -04:00
2018-10-17 03:13:26 -04:00
expect(
component.$el.querySelector('.table-section.js-pipeline-stages').textContent.trim(),
).toEqual('Stages');
});
});
describe('without data', () => {
it('should render an empty table', () => {
const component = new PipelinesTableComponent({
propsData: {
pipelines: [],
autoDevopsHelpPath: 'foo',
2017-10-23 09:36:02 -04:00
viewType: 'root',
},
}).$mount();
2018-10-09 14:03:09 -04:00
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0);
});
});
describe('with data', () => {
it('should render rows', () => {
const component = new PipelinesTableComponent({
propsData: {
pipelines: [pipeline],
autoDevopsHelpPath: 'foo',
2017-10-23 09:36:02 -04:00
viewType: 'root',
},
}).$mount();
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(1);
});
});
});