debian-mirror-gitlab/spec/frontend/groups/components/item_caret_spec.js
2021-03-11 19:13:27 +05:30

48 lines
1.1 KiB
JavaScript

import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ItemCaret from '~/groups/components/item_caret.vue';
describe('ItemCaret', () => {
let wrapper;
const defaultProps = {
isGroupOpen: false,
};
const createComponent = (props = {}) => {
wrapper = shallowMount(ItemCaret, {
propsData: { ...defaultProps, ...props },
});
};
afterEach(() => {
if (wrapper) {
wrapper.destroy();
wrapper = null;
}
});
const findAllGlIcons = () => wrapper.findAll(GlIcon);
const findGlIcon = () => wrapper.find(GlIcon);
describe('template', () => {
it('renders component template correctly', () => {
createComponent();
expect(wrapper.classes()).toContain('folder-caret');
expect(findAllGlIcons()).toHaveLength(1);
});
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);
});
});
});