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

86 lines
2.2 KiB
JavaScript
Raw Normal View History

2018-10-15 14:42:47 +05:30
import Vue from 'vue';
2018-12-13 13:39:08 +05:30
import JobGroupDropdown from '~/pipelines/components/graph/job_group_dropdown.vue';
2018-10-15 14:42:47 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2018-12-13 13:39:08 +05:30
describe('job group dropdown component', () => {
const Component = Vue.extend(JobGroupDropdown);
2018-10-15 14:42:47 +05:30
let vm;
2018-12-13 13:39:08 +05:30
const group = {
2018-10-15 14:42:47 +05:30
jobs: [
{
id: 4256,
name: '<img src=x onerror=alert(document.domain)>',
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
text: 'passed',
label: 'passed',
tooltip: 'passed',
group: 'success',
details_path: '/root/ci-mock/builds/4256',
has_details: true,
action: {
icon: 'retry',
title: 'Retry',
path: '/root/ci-mock/builds/4256/retry',
method: 'post',
},
},
},
{
id: 4299,
name: 'test',
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
text: 'passed',
label: 'passed',
tooltip: 'passed',
group: 'success',
details_path: '/root/ci-mock/builds/4299',
has_details: true,
action: {
icon: 'retry',
title: 'Retry',
path: '/root/ci-mock/builds/4299/retry',
method: 'post',
},
},
},
],
name: 'rspec:linux',
size: 2,
status: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
text: 'passed',
label: 'passed',
tooltip: 'passed',
group: 'success',
details_path: '/root/ci-mock/builds/4256',
has_details: true,
action: {
icon: 'retry',
title: 'Retry',
path: '/root/ci-mock/builds/4256/retry',
method: 'post',
},
},
};
afterEach(() => {
vm.$destroy();
});
beforeEach(() => {
2018-12-13 13:39:08 +05:30
vm = mountComponent(Component, { group });
2018-10-15 14:42:47 +05:30
});
2018-12-13 13:39:08 +05:30
it('renders button with group name and size', () => {
expect(vm.$el.querySelector('button').textContent).toContain(group.name);
expect(vm.$el.querySelector('button').textContent).toContain(group.size);
2018-10-15 14:42:47 +05:30
});
it('renders dropdown with jobs', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelectorAll('.scrollable-menu>ul>li').length).toEqual(group.jobs.length);
2018-10-15 14:42:47 +05:30
});
});