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.

49 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-07-16 23:28:13 +05:30
import { GlBadge, GlIcon } 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) {
2022-07-16 23:28:13 +05:30
wrapper = shallowMount(StatusBox, { propsData, stubs: { GlBadge } });
2021-03-08 18:12:59 +05:30
}
describe('Merge request status box component', () => {
2022-07-16 23:28:13 +05:30
const findBadge = () => wrapper.findComponent(GlBadge);
describe.each`
issuableType | badgeText | initialState | badgeClass | badgeVariant | badgeIcon
${'merge_request'} | ${'Open'} | ${'opened'} | ${'issuable-status-badge-open'} | ${'success'} | ${'merge-request-open'}
${'merge_request'} | ${'Closed'} | ${'closed'} | ${'issuable-status-badge-closed'} | ${'danger'} | ${'merge-request-close'}
${'merge_request'} | ${'Merged'} | ${'merged'} | ${'issuable-status-badge-merged'} | ${'info'} | ${'merge'}
${'issue'} | ${'Open'} | ${'opened'} | ${'issuable-status-badge-open'} | ${'success'} | ${'issues'}
${'issue'} | ${'Closed'} | ${'closed'} | ${'issuable-status-badge-closed'} | ${'info'} | ${'issue-closed'}
`(
'with issuableType set to "$issuableType" and state set to "$initialState"',
({ issuableType, badgeText, initialState, badgeClass, badgeVariant, badgeIcon }) => {
beforeEach(() => {
2021-03-08 18:12:59 +05:30
factory({
2022-07-16 23:28:13 +05:30
initialState,
issuableType,
2021-03-08 18:12:59 +05:30
});
});
2022-07-16 23:28:13 +05:30
it(`renders badge with text '${badgeText}'`, () => {
expect(findBadge().text()).toBe(badgeText);
});
2021-03-08 18:12:59 +05:30
2022-07-16 23:28:13 +05:30
it(`sets badge css class as '${badgeClass}'`, () => {
expect(findBadge().classes()).toContain(badgeClass);
2021-03-08 18:12:59 +05:30
});
2022-07-16 23:28:13 +05:30
it(`sets badge variant as '${badgeVariant}`, () => {
expect(findBadge().props('variant')).toBe(badgeVariant);
});
2021-03-08 18:12:59 +05:30
2022-07-16 23:28:13 +05:30
it(`sets badge icon as '${badgeIcon}'`, () => {
expect(findBadge().findComponent(GlIcon).props('name')).toBe(badgeIcon);
2021-03-08 18:12:59 +05:30
});
2022-07-16 23:28:13 +05:30
},
);
2021-03-08 18:12:59 +05:30
});