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

disclosure_hierarchy_item_spec.js « work_item_ancestors « components « work_items « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2cfe61654ad6c94afcf287b133a5a3f596bed61a (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
47
48
49
50
51
52
53
import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';

import DisclosureHierarchyItem from '~/work_items/components/work_item_ancestors/disclosure_hierarchy_item.vue';
import { mockDisclosureHierarchyItems } from './mock_data';

describe('DisclosurePathItem', () => {
  let wrapper;

  const findIcon = () => wrapper.findComponent(GlIcon);

  const createComponent = (props = {}, options = {}) => {
    return shallowMount(DisclosureHierarchyItem, {
      propsData: {
        item: mockDisclosureHierarchyItems[0],
        ...props,
      },
      ...options,
    });
  };

  beforeEach(() => {
    wrapper = createComponent();
  });

  describe('renders the item', () => {
    it('renders the inline icon', () => {
      expect(findIcon().exists()).toBe(true);
      expect(findIcon().props('name')).toBe(mockDisclosureHierarchyItems[0].icon);
    });
  });

  describe('item slot', () => {
    beforeEach(() => {
      wrapper = createComponent(null, {
        scopedSlots: {
          default: `
            <div
              data-testid="item-slot-content">
              {{ props.item.title }}
            </div>
          `,
        },
      });
    });

    it('contains all elements passed into the additional slot', () => {
      const item = wrapper.find('[data-testid="item-slot-content"]');

      expect(item.text()).toBe(mockDisclosureHierarchyItems[0].title);
    });
  });
});