debian-mirror-gitlab/spec/javascripts/pipelines/pipelines_table_spec.js

68 lines
2.1 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2017-09-10 17:25:29 +05:30
import pipelinesTableComp from '~/pipelines/components/pipelines_table.vue';
2017-08-17 22:00:37 +05:30
import '~/lib/utils/datetime_utility';
describe('Pipelines Table', () => {
2017-09-10 17:25:29 +05:30
const jsonFixtureName = 'pipelines/pipelines.json';
let pipeline;
2017-08-17 22:00:37 +05:30
let PipelinesTableComponent;
2017-09-10 17:25:29 +05:30
preloadFixtures(jsonFixtureName);
2017-08-17 22:00:37 +05:30
beforeEach(() => {
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
2017-09-10 17:25:29 +05:30
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
pipeline = pipelines.find(p => p.id === 1);
2017-08-17 22:00:37 +05:30
});
describe('table', () => {
let component;
beforeEach(() => {
component = new PipelinesTableComponent({
propsData: {
pipelines: [],
},
}).$mount();
});
afterEach(() => {
component.$destroy();
});
it('should render a table', () => {
2017-09-10 17:25:29 +05:30
expect(component.$el.getAttribute('class')).toContain('ci-table');
2017-08-17 22:00:37 +05:30
});
it('should render table head with correct columns', () => {
2017-09-10 17:25:29 +05:30
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-08-17 22:00:37 +05:30
});
});
describe('without data', () => {
it('should render an empty table', () => {
const component = new PipelinesTableComponent({
propsData: {
pipelines: [],
},
}).$mount();
2017-09-10 17:25:29 +05:30
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0);
2017-08-17 22:00:37 +05:30
});
});
describe('with data', () => {
it('should render rows', () => {
const component = new PipelinesTableComponent({
propsData: {
pipelines: [pipeline],
},
}).$mount();
2017-09-10 17:25:29 +05:30
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(1);
2017-08-17 22:00:37 +05:30
});
});
});