debian-mirror-gitlab/spec/javascripts/vue_shared/components/ci_icon_spec.js

123 lines
2.9 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
import ciIcon from '~/vue_shared/components/ci_icon.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('CI Icon component', () => {
2018-10-15 14:42:47 +05:30
const Component = Vue.extend(ciIcon);
let vm;
afterEach(() => {
vm.$destroy();
2017-08-17 22:00:37 +05:30
});
it('should render a span element with an svg', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_success',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.tagName).toEqual('SPAN');
expect(vm.$el.querySelector('span > svg')).toBeDefined();
2017-08-17 22:00:37 +05:30
});
it('should render a success status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_success',
group: 'success',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-success')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render a failed status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_failed',
group: 'failed',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-failed')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render success with warnings status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_warning',
group: 'warning',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-warning')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render pending status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_pending',
group: 'pending',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-pending')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render running status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_running',
group: 'running',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-running')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render created status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_created',
group: 'created',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-created')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render skipped status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_skipped',
group: 'skipped',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-skipped')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render canceled status', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_canceled',
group: 'canceled',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-canceled')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
it('should render status for manual action', () => {
2018-10-15 14:42:47 +05:30
vm = mountComponent(Component, {
status: {
icon: 'icon_status_manual',
group: 'manual',
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
expect(vm.$el.classList.contains('ci-status-icon-manual')).toEqual(true);
2017-08-17 22:00:37 +05:30
});
});