2017-03-17 13:30:32 -04:00
|
|
|
import Vue from 'vue';
|
2017-06-20 10:54:55 -04:00
|
|
|
import pipelinesTableComp from '~/pipelines/components/pipelines_table.vue';
|
2017-03-17 13:30:32 -04:00
|
|
|
import '~/lib/utils/datetime_utility';
|
2017-01-29 10:30:04 -05:00
|
|
|
|
|
|
|
describe('Pipelines Table', () => {
|
2017-05-05 06:34:42 -04:00
|
|
|
const jsonFixtureName = 'pipelines/pipelines.json';
|
|
|
|
|
|
|
|
let pipeline;
|
2017-03-17 13:30:32 -04:00
|
|
|
let PipelinesTableComponent;
|
2017-01-29 10:30:04 -05:00
|
|
|
|
2017-05-05 06:34:42 -04:00
|
|
|
preloadFixtures(jsonFixtureName);
|
|
|
|
|
2017-01-29 10:30:04 -05:00
|
|
|
beforeEach(() => {
|
2018-06-16 17:50:13 -04:00
|
|
|
const { pipelines } = getJSONFixture(jsonFixtureName);
|
2018-01-24 13:36:54 -05:00
|
|
|
|
2017-03-17 13:30:32 -04:00
|
|
|
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
|
2018-01-24 13:36:54 -05:00
|
|
|
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
|
2017-01-29 10:30:04 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('table', () => {
|
|
|
|
let component;
|
|
|
|
beforeEach(() => {
|
2017-03-17 13:30:32 -04:00
|
|
|
component = new PipelinesTableComponent({
|
2017-01-29 10:30:04 -05:00
|
|
|
propsData: {
|
|
|
|
pipelines: [],
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-10-23 09:36:02 -04:00
|
|
|
viewType: 'root',
|
2017-01-29 10:30:04 -05:00
|
|
|
},
|
2017-03-17 13:30:32 -04:00
|
|
|
}).$mount();
|
2017-01-29 10:30:04 -05:00
|
|
|
});
|
|
|
|
|
2017-03-22 22:39:09 -04:00
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
2017-01-29 10:30:04 -05:00
|
|
|
it('should render a table', () => {
|
2017-06-16 08:00:28 -04:00
|
|
|
expect(component.$el.getAttribute('class')).toContain('ci-table');
|
2017-01-29 10:30:04 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
2017-01-29 10:30:04 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without data', () => {
|
|
|
|
it('should render an empty table', () => {
|
2017-03-17 13:30:32 -04:00
|
|
|
const component = new PipelinesTableComponent({
|
2017-01-29 10:30:04 -05:00
|
|
|
propsData: {
|
|
|
|
pipelines: [],
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-10-23 09:36:02 -04:00
|
|
|
viewType: 'root',
|
2017-01-29 10:30:04 -05:00
|
|
|
},
|
2017-03-17 13:30:32 -04:00
|
|
|
}).$mount();
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-06-16 08:00:28 -04:00
|
|
|
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0);
|
2017-01-29 10:30:04 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with data', () => {
|
|
|
|
it('should render rows', () => {
|
2017-03-17 13:30:32 -04:00
|
|
|
const component = new PipelinesTableComponent({
|
2017-01-29 10:30:04 -05:00
|
|
|
propsData: {
|
|
|
|
pipelines: [pipeline],
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-10-23 09:36:02 -04:00
|
|
|
viewType: 'root',
|
2017-01-29 10:30:04 -05:00
|
|
|
},
|
2017-03-17 13:30:32 -04:00
|
|
|
}).$mount();
|
2017-01-29 10:30:04 -05:00
|
|
|
|
2017-06-16 08:00:28 -04:00
|
|
|
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(1);
|
2017-01-29 10:30:04 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|