debian-mirror-gitlab/spec/frontend/groups/components/item_caret_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.1 KiB
JavaScript
Raw Normal View History

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
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
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
});
});
});