debian-mirror-gitlab/spec/frontend/vue_shared/components/ci_badge_link_spec.js

101 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2020-05-24 23:13:21 +05:30
import mountComponent from 'helpers/vue_mount_component_helper';
2020-01-01 13:55:28 +05:30
import ciBadge from '~/vue_shared/components/ci_badge_link.vue';
2017-08-17 22:00:37 +05:30
describe('CI Badge Link Component', () => {
let CIBadge;
2018-03-17 18:26:18 +05:30
let vm;
2017-08-17 22:00:37 +05:30
const statuses = {
canceled: {
text: 'canceled',
label: 'canceled',
group: 'canceled',
2018-03-17 18:26:18 +05:30
icon: 'status_canceled',
2017-08-17 22:00:37 +05:30
details_path: 'status/canceled',
},
created: {
text: 'created',
label: 'created',
group: 'created',
2018-03-17 18:26:18 +05:30
icon: 'status_created',
2017-08-17 22:00:37 +05:30
details_path: 'status/created',
},
failed: {
text: 'failed',
label: 'failed',
group: 'failed',
2018-03-17 18:26:18 +05:30
icon: 'status_failed',
2017-08-17 22:00:37 +05:30
details_path: 'status/failed',
},
manual: {
text: 'manual',
label: 'manual action',
group: 'manual',
2018-03-17 18:26:18 +05:30
icon: 'status_manual',
2017-08-17 22:00:37 +05:30
details_path: 'status/manual',
},
pending: {
text: 'pending',
label: 'pending',
group: 'pending',
2018-03-17 18:26:18 +05:30
icon: 'status_pending',
2017-08-17 22:00:37 +05:30
details_path: 'status/pending',
},
running: {
text: 'running',
label: 'running',
group: 'running',
2018-03-17 18:26:18 +05:30
icon: 'status_running',
2017-08-17 22:00:37 +05:30
details_path: 'status/running',
},
skipped: {
text: 'skipped',
label: 'skipped',
group: 'skipped',
2018-03-17 18:26:18 +05:30
icon: 'status_skipped',
2017-08-17 22:00:37 +05:30
details_path: 'status/skipped',
},
success_warining: {
text: 'passed',
label: 'passed',
2019-07-31 22:56:46 +05:30
group: 'success-with-warnings',
2018-03-17 18:26:18 +05:30
icon: 'status_warning',
2017-08-17 22:00:37 +05:30
details_path: 'status/warning',
},
success: {
text: 'passed',
label: 'passed',
group: 'passed',
2018-03-17 18:26:18 +05:30
icon: 'status_success',
2017-08-17 22:00:37 +05:30
details_path: 'status/passed',
},
};
2018-03-17 18:26:18 +05:30
beforeEach(() => {
2017-08-17 22:00:37 +05:30
CIBadge = Vue.extend(ciBadge);
2018-03-17 18:26:18 +05:30
});
afterEach(() => {
vm.$destroy();
});
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
it('should render each status badge', () => {
2018-12-13 13:39:08 +05:30
Object.keys(statuses).map(status => {
2018-03-17 18:26:18 +05:30
vm = mountComponent(CIBadge, { status: statuses[status] });
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(vm.$el.getAttribute('href')).toEqual(statuses[status].details_path);
expect(vm.$el.textContent.trim()).toEqual(statuses[status].text);
2018-12-13 13:39:08 +05:30
expect(vm.$el.getAttribute('class')).toContain(`ci-status ci-${statuses[status].group}`);
2017-08-17 22:00:37 +05:30
expect(vm.$el.querySelector('svg')).toBeDefined();
return vm;
});
});
2018-03-17 18:26:18 +05:30
it('should not render label', () => {
vm = mountComponent(CIBadge, { status: statuses.canceled, showText: false });
2018-12-13 13:39:08 +05:30
2018-03-17 18:26:18 +05:30
expect(vm.$el.textContent.trim()).toEqual('');
});
2017-08-17 22:00:37 +05:30
});