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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
2.8 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
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', () => {
2021-03-11 19:13:27 +05:30
let wrapper;
2018-10-15 14:42:47 +05:30
2022-07-23 23:45:48 +05:30
const findIconWrapper = () => wrapper.find('[data-testid="ci-icon-wrapper"]');
2018-10-15 14:42:47 +05:30
afterEach(() => {
2021-03-11 19:13:27 +05:30
wrapper.destroy();
wrapper = null;
2017-08-17 22:00:37 +05:30
});
it('should render a span element with an svg', () => {
2021-03-11 19:13:27 +05:30
wrapper = shallowMount(ciIcon, {
propsData: {
status: {
icon: 'status_success',
},
},
});
expect(wrapper.find('span').exists()).toBe(true);
2022-08-27 11:52:29 +05:30
expect(wrapper.findComponent(GlIcon).exists()).toBe(true);
2021-03-11 19:13:27 +05:30
});
2022-07-23 23:45:48 +05:30
describe('active icons', () => {
it.each`
isActive | cssClass
${true} | ${'active'}
${false} | ${'active'}
`('active should be $isActive', ({ isActive, cssClass }) => {
wrapper = shallowMount(ciIcon, {
propsData: {
status: {
icon: 'status_success',
},
isActive,
},
});
if (isActive) {
expect(findIconWrapper().classes()).toContain(cssClass);
} else {
expect(findIconWrapper().classes()).not.toContain(cssClass);
}
});
});
describe('interactive icons', () => {
it.each`
isInteractive | cssClass
${true} | ${'interactive'}
${false} | ${'interactive'}
`('interactive should be $isInteractive', ({ isInteractive, cssClass }) => {
wrapper = shallowMount(ciIcon, {
propsData: {
status: {
icon: 'status_success',
},
isInteractive,
},
});
if (isInteractive) {
expect(findIconWrapper().classes()).toContain(cssClass);
} else {
expect(findIconWrapper().classes()).not.toContain(cssClass);
}
});
});
2021-03-11 19:13:27 +05:30
describe('rendering a status', () => {
it.each`
icon | group | cssClass
${'status_success'} | ${'success'} | ${'ci-status-icon-success'}
${'status_failed'} | ${'failed'} | ${'ci-status-icon-failed'}
${'status_warning'} | ${'warning'} | ${'ci-status-icon-warning'}
${'status_pending'} | ${'pending'} | ${'ci-status-icon-pending'}
${'status_running'} | ${'running'} | ${'ci-status-icon-running'}
${'status_created'} | ${'created'} | ${'ci-status-icon-created'}
${'status_skipped'} | ${'skipped'} | ${'ci-status-icon-skipped'}
${'status_canceled'} | ${'canceled'} | ${'ci-status-icon-canceled'}
${'status_manual'} | ${'manual'} | ${'ci-status-icon-manual'}
`('should render a $group status', ({ icon, group, cssClass }) => {
wrapper = shallowMount(ciIcon, {
propsData: {
status: {
icon,
group,
},
},
});
expect(wrapper.classes()).toContain(cssClass);
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
});
});