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

history_item_spec.js « registry « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d51ddda2e3e6bf7a90a471162930260f37156aff (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { shallowMount } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import component from '~/vue_shared/components/registry/history_item.vue';

describe('History Item', () => {
  let wrapper;
  const defaultProps = {
    icon: 'pencil',
  };

  const mountComponent = () => {
    wrapper = shallowMount(component, {
      propsData: { ...defaultProps },
      stubs: {
        TimelineEntryItem,
      },
      slots: {
        default: '<div data-testid="default-slot"></div>',
        body: '<div data-testid="body-slot"></div>',
      },
    });
  };

  afterEach(() => {
    wrapper.destroy();
    wrapper = null;
  });

  const findTimelineEntry = () => wrapper.find(TimelineEntryItem);
  const findGlIcon = () => wrapper.find(GlIcon);
  const findDefaultSlot = () => wrapper.find('[data-testid="default-slot"]');
  const findBodySlot = () => wrapper.find('[data-testid="body-slot"]');

  it('renders the correct markup', () => {
    mountComponent();

    expect(wrapper.element).toMatchSnapshot();
  });

  it('has a default slot', () => {
    mountComponent();

    expect(findDefaultSlot().exists()).toBe(true);
  });

  it('has a body slot', () => {
    mountComponent();

    expect(findBodySlot().exists()).toBe(true);
  });

  it('has a timeline entry', () => {
    mountComponent();

    expect(findTimelineEntry().exists()).toBe(true);
  });

  it('has an icon', () => {
    mountComponent();

    const icon = findGlIcon();

    expect(icon.exists()).toBe(true);
    expect(icon.attributes('name')).toBe(defaultProps.icon);
  });
});