debian-mirror-gitlab/spec/javascripts/pipelines/graph/graph_component_spec.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2018-10-15 14:42:47 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2017-08-17 22:00:37 +05:30
import graphComponent from '~/pipelines/components/graph/graph_component.vue';
import graphJSON from './mock_data';
describe('graph component', () => {
2018-10-15 14:42:47 +05:30
const GraphComponent = Vue.extend(graphComponent);
let component;
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
afterEach(() => {
component.$destroy();
2017-08-17 22:00:37 +05:30
});
describe('while is loading', () => {
it('should render a loading icon', () => {
2018-10-15 14:42:47 +05:30
component = mountComponent(GraphComponent, {
isLoading: true,
pipeline: {},
});
2017-08-17 22:00:37 +05:30
expect(component.$el.querySelector('.loading-icon')).toBeDefined();
});
});
2017-09-10 17:25:29 +05:30
describe('with data', () => {
it('should render the graph', () => {
2018-10-15 14:42:47 +05:30
component = mountComponent(GraphComponent, {
isLoading: false,
pipeline: graphJSON,
});
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(component.$el.classList.contains('js-pipeline-graph')).toEqual(true);
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(
component.$el.querySelector('.stage-column:first-child').classList.contains('no-margin'),
).toEqual(true);
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(
component.$el.querySelector('.stage-column:nth-child(2)').classList.contains('left-margin'),
).toEqual(true);
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(
2018-12-13 13:39:08 +05:30
component.$el
.querySelector('.stage-column:nth-child(2) .build:nth-child(1)')
.classList.contains('left-connector'),
2017-09-10 17:25:29 +05:30
).toEqual(true);
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(component.$el.querySelector('loading-icon')).toBe(null);
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(component.$el.querySelector('.stage-column-list')).toBeDefined();
2017-08-17 22:00:37 +05:30
});
});
2018-10-15 14:42:47 +05:30
describe('capitalizeStageName', () => {
it('capitalizes and escapes stage name', () => {
component = mountComponent(GraphComponent, {
isLoading: false,
pipeline: graphJSON,
});
2018-12-13 13:39:08 +05:30
expect(
component.$el.querySelector('.stage-column:nth-child(2) .stage-name').textContent.trim(),
).toEqual('Deploy <img src=x onerror=alert(document.domain)>');
2018-10-15 14:42:47 +05:30
});
});
2017-08-17 22:00:37 +05:30
});