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