Welcome to mirror list, hosted at ThFree Co, Russian Federation.

group_folder_spec.js « components « groups « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b274c01a43be826391f3fce7ccc7c4aa969d8f60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import GroupFolder from '~/groups/components/group_folder.vue';
import GroupItem from 'jh_else_ce/groups/components/group_item.vue';
import { MAX_CHILDREN_COUNT } from '~/groups/constants';
import { mockGroups, mockParentGroupItem } from '../mock_data';

describe('GroupFolder component', () => {
  let wrapper;

  Vue.component('GroupItem', GroupItem);

  const findLink = () => wrapper.find('a');

  const createComponent = ({ groups = mockGroups, parentGroup = mockParentGroupItem } = {}) =>
    shallowMount(GroupFolder, {
      propsData: {
        groups,
        parentGroup,
      },
    });

  it('does not render more children stats link when children count of group is under limit', () => {
    wrapper = createComponent();

    expect(findLink().exists()).toBe(false);
  });

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

    expect(findLink().text()).toBe(`${childrenCount} more items`);
  });

  it('renders group items', () => {
    wrapper = createComponent();

    expect(wrapper.findAllComponents(GroupItem)).toHaveLength(7);
  });
});