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

73 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
import stageColumnComponent from '~/pipelines/components/graph/stage_column_component.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
describe('stage column component', () => {
let component;
2018-10-15 14:42:47 +05:30
const StageColumnComponent = Vue.extend(stageColumnComponent);
2017-08-17 22:00:37 +05:30
const mockJob = {
2018-03-17 18:26:18 +05:30
id: 4250,
2017-08-17 22:00:37 +05:30
name: 'test',
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2017-08-17 22:00:37 +05:30
text: 'passed',
label: 'passed',
group: 'success',
2018-03-17 18:26:18 +05:30
details_path: '/root/ci-mock/builds/4250',
2017-08-17 22:00:37 +05:30
action: {
2018-03-17 18:26:18 +05:30
icon: 'retry',
2017-08-17 22:00:37 +05:30
title: 'Retry',
2018-03-17 18:26:18 +05:30
path: '/root/ci-mock/builds/4250/retry',
2017-08-17 22:00:37 +05:30
method: 'post',
},
},
};
beforeEach(() => {
2018-11-08 19:23:39 +05:30
2018-03-17 18:26:18 +05:30
const mockJobs = [];
for (let i = 0; i < 3; i += 1) {
const mockedJob = Object.assign({}, mockJob);
mockedJob.id += i;
mockJobs.push(mockedJob);
}
2018-10-15 14:42:47 +05:30
component = mountComponent(StageColumnComponent, {
title: 'foo',
jobs: mockJobs,
});
2017-08-17 22:00:37 +05:30
});
it('should render provided title', () => {
expect(component.$el.querySelector('.stage-name').textContent.trim()).toEqual('foo');
});
it('should render the provided jobs', () => {
expect(component.$el.querySelectorAll('.builds-container > ul > li').length).toEqual(3);
});
2018-10-15 14:42:47 +05:30
describe('jobId', () => {
it('escapes job name', () => {
component = mountComponent(StageColumnComponent, {
jobs: [
{
id: 4259,
name: '<img src=x onerror=alert(document.domain)>',
status: {
icon: 'icon_status_success',
label: 'success',
tooltip: '<img src=x onerror=alert(document.domain)>',
},
},
],
title: 'test',
});
expect(
component.$el.querySelector('.builds-container li').getAttribute('id'),
).toEqual('ci-badge-&lt;img src=x onerror=alert(document.domain)&gt;');
});
});
2017-08-17 22:00:37 +05:30
});