2021-01-03 14:25:43 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { GlIcon } from '@gitlab/ui';
|
|
|
|
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
|
|
|
|
|
|
|
afterEach(() => {
|
2021-01-03 14:25:43 +05:30
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
}
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
const findAllGlIcons = () => wrapper.findAll(GlIcon);
|
|
|
|
const findGlIcon = () => wrapper.find(GlIcon);
|
|
|
|
|
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
|
|
|
|
${true} | ${'angle-down'}
|
|
|
|
${false} | ${'angle-right'}
|
|
|
|
`('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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|