blob: f3652f1a41023b0cf02c8497c097f4481068cebf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ItemTypeIcon from '~/groups/components/item_type_icon.vue';
import { ITEM_TYPE } from '../mock_data';
describe('ItemTypeIcon', () => {
let wrapper;
const defaultProps = {
itemType: ITEM_TYPE.GROUP,
};
const createComponent = (props = {}) => {
wrapper = shallowMount(ItemTypeIcon, {
propsData: { ...defaultProps, ...props },
});
};
afterEach(() => {
if (wrapper) {
wrapper.destroy();
wrapper = null;
}
});
const findGlIcon = () => wrapper.find(GlIcon);
describe('template', () => {
it('renders component template correctly', () => {
createComponent();
expect(wrapper.classes()).toContain('item-type-icon');
});
it.each`
type | icon
${ITEM_TYPE.GROUP} | ${'subgroup'}
${ITEM_TYPE.PROJECT} | ${'project'}
`('shows "$icon" icon when `itemType` is "$type"', ({ type, icon }) => {
createComponent({
itemType: type,
});
expect(findGlIcon().props('name')).toBe(icon);
});
});
});
|