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

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

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-08-13 15:12:31 +05:30
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import GroupFolder from '~/groups/components/group_folder.vue';
import GroupItem from '~/groups/components/group_item.vue';
import { MAX_CHILDREN_COUNT } from '~/groups/constants';
2018-03-17 18:26:18 +05:30
import { mockGroups, mockParentGroupItem } from '../mock_data';
2022-08-13 15:12:31 +05:30
describe('GroupFolder component', () => {
let wrapper;
2018-03-17 18:26:18 +05:30
2022-08-13 15:12:31 +05:30
Vue.component('GroupItem', GroupItem);
2018-03-17 18:26:18 +05:30
2022-08-13 15:12:31 +05:30
const findLink = () => wrapper.find('a');
2018-03-17 18:26:18 +05:30
2022-08-13 15:12:31 +05:30
const createComponent = ({ groups = mockGroups, parentGroup = mockParentGroupItem } = {}) =>
shallowMount(GroupFolder, {
propsData: {
groups,
parentGroup,
},
});
2018-03-17 18:26:18 +05:30
afterEach(() => {
2022-08-13 15:12:31 +05:30
wrapper.destroy();
2018-03-17 18:26:18 +05:30
});
2022-08-13 15:12:31 +05:30
it('does not render more children stats link when children count of group is under limit', () => {
wrapper = createComponent();
2018-03-17 18:26:18 +05:30
2022-08-13 15:12:31 +05:30
expect(findLink().exists()).toBe(false);
2018-03-17 18:26:18 +05:30
});
2022-08-13 15:12:31 +05:30
it('renders text of count of excess children when children count of group is over limit', () => {
const childrenCount = MAX_CHILDREN_COUNT + 1;
wrapper = createComponent({
parentGroup: {
...mockParentGroupItem,
childrenCount,
},
2018-03-17 18:26:18 +05:30
});
2022-08-13 15:12:31 +05:30
expect(findLink().text()).toBe(`${childrenCount} more items`);
});
2018-03-17 18:26:18 +05:30
2022-08-13 15:12:31 +05:30
it('renders group items', () => {
wrapper = createComponent();
2018-12-13 13:39:08 +05:30
2022-08-13 15:12:31 +05:30
expect(wrapper.findAllComponents(GroupItem)).toHaveLength(7);
2018-03-17 18:26:18 +05:30
});
});