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';
2018-10-15 14:42:47 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2020-01-01 13:55:28 +05:30
import ciIcon from '~/vue_shared/components/ci_icon.vue';
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: {
2018-11-18 11:00:15 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_failed',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_warning',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_pending',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_running',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_created',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_skipped',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_canceled',
2018-10-15 14:42:47 +05:30
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: {
2018-11-18 11:00:15 +05:30
icon: 'status_manual',
2018-10-15 14:42:47 +05:30
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
});
});