debian-mirror-gitlab/spec/frontend/issuable/components/status_box_spec.js

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

72 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-09-04 01:27:46 +05:30
import { GlIcon, GlSprintf } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
2021-06-08 01:23:25 +05:30
import StatusBox from '~/issuable/components/status_box.vue';
2021-03-08 18:12:59 +05:30
let wrapper;
function factory(propsData) {
wrapper = shallowMount(StatusBox, { propsData, stubs: { GlSprintf } });
}
const testCases = [
{
name: 'Open',
state: 'opened',
class: 'status-box-open',
icon: 'issue-open-m',
},
2021-03-11 19:13:27 +05:30
{
name: 'Open',
state: 'locked',
class: 'status-box-open',
icon: 'issue-open-m',
},
2021-03-08 18:12:59 +05:30
{
name: 'Closed',
state: 'closed',
class: 'status-box-mr-closed',
2021-04-29 21:17:54 +05:30
icon: 'issue-close',
2021-03-08 18:12:59 +05:30
},
{
name: 'Merged',
state: 'merged',
class: 'status-box-mr-merged',
icon: 'git-merge',
},
];
describe('Merge request status box component', () => {
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
testCases.forEach((testCase) => {
describe(`when merge request is ${testCase.name}`, () => {
it('renders human readable test', () => {
factory({
initialState: testCase.state,
});
expect(wrapper.text()).toContain(testCase.name);
});
it('sets css class', () => {
factory({
initialState: testCase.state,
});
expect(wrapper.classes()).toContain(testCase.class);
});
it('renders icon', () => {
factory({
initialState: testCase.state,
});
2021-09-04 01:27:46 +05:30
expect(wrapper.findComponent(GlIcon).props('name')).toBe(testCase.icon);
2021-03-08 18:12:59 +05:30
});
});
});
});