2017-03-17 13:30:32 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import pipelinesTableComp from '~/vue_shared/components/pipelines_table';
|
|
|
|
import '~/lib/utils/datetime_utility';
|
|
|
|
import pipeline from '../../commit/pipelines/mock_data';
|
2017-01-29 10:30:04 -05:00
|
|
|
|
|
|
|
describe('Pipelines Table', () => {
|
2017-03-17 13:30:32 -04:00
|
|
|
let PipelinesTableComponent;
|
2017-01-29 10:30:04 -05:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-03-17 13:30:32 -04:00
|
|
|
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
|
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
|
|
|
service: {},
|
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', () => {
|
|
|
|
expect(component.$el).toEqual('TABLE');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render table head with correct columns', () => {
|
|
|
|
expect(component.$el.querySelector('th.js-pipeline-status').textContent).toEqual('Status');
|
|
|
|
expect(component.$el.querySelector('th.js-pipeline-info').textContent).toEqual('Pipeline');
|
|
|
|
expect(component.$el.querySelector('th.js-pipeline-commit').textContent).toEqual('Commit');
|
|
|
|
expect(component.$el.querySelector('th.js-pipeline-stages').textContent).toEqual('Stages');
|
|
|
|
expect(component.$el.querySelector('th.js-pipeline-date').textContent).toEqual('');
|
|
|
|
expect(component.$el.querySelector('th.js-pipeline-actions').textContent).toEqual('');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
service: {},
|
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
|
|
|
expect(component.$el.querySelectorAll('tbody tr').length).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
|
|
|
pipelines: [pipeline],
|
2017-03-17 13:30:32 -04:00
|
|
|
service: {},
|
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
|
|
|
|
|
|
|
expect(component.$el.querySelectorAll('tbody tr').length).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|