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(() => {
|
2017-03-17 13:30:32 -04:00
|
|
|
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
|
2017-05-05 06:34:42 -04:00
|
|
|
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
|
|
|
|
pipeline = pipelines.find(p => p.id === 1);
|
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-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', () => {
|
2017-06-16 08:00:28 -04:00
|
|
|
expect(component.$el.querySelector('.table-section.js-pipeline-status').textContent.trim()).toEqual('Status');
|
|
|
|
expect(component.$el.querySelector('.table-section.js-pipeline-info').textContent.trim()).toEqual('Pipeline');
|
|
|
|
expect(component.$el.querySelector('.table-section.js-pipeline-commit').textContent.trim()).toEqual('Commit');
|
|
|
|
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-03-17 13:30:32 -04:00
|
|
|
}).$mount();
|
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-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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|