2021-01-03 14:25:43 +05:30
|
|
|
import { GlIcon } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2021-01-03 14:25:43 +05:30
|
|
|
import ItemCaret from '~/groups/components/item_caret.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
describe('ItemCaret', () => {
|
|
|
|
let wrapper;
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
const defaultProps = {
|
|
|
|
isGroupOpen: false,
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
const createComponent = (props = {}) => {
|
|
|
|
wrapper = shallowMount(ItemCaret, {
|
|
|
|
propsData: { ...defaultProps, ...props },
|
|
|
|
});
|
|
|
|
};
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
const findAllGlIcons = () => wrapper.findAllComponents(GlIcon);
|
|
|
|
const findGlIcon = () => wrapper.findComponent(GlIcon);
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('template', () => {
|
2021-01-03 14:25:43 +05:30
|
|
|
it('renders component template correctly', () => {
|
|
|
|
createComponent();
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(wrapper.classes()).toContain('folder-caret');
|
|
|
|
expect(findAllGlIcons()).toHaveLength(1);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it.each`
|
|
|
|
isGroupOpen | icon
|
2022-07-23 23:45:48 +05:30
|
|
|
${true} | ${'chevron-down'}
|
|
|
|
${false} | ${'chevron-right'}
|
2021-01-03 14:25:43 +05:30
|
|
|
`('renders "$icon" icon when `isGroupOpen` is $isGroupOpen', ({ isGroupOpen, icon }) => {
|
|
|
|
createComponent({
|
|
|
|
isGroupOpen,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(findGlIcon().props('name')).toBe(icon);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|