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

discussion_filter_note_spec.js « components « notes « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d35f8f7c28db8b831b1426d4116b8ea0a7736448 (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
import { shallowMount } from '@vue/test-utils';
import { GlButton, GlSprintf } from '@gitlab/ui';
import DiscussionFilterNote from '~/notes/components/discussion_filter_note.vue';
import eventHub from '~/notes/event_hub';

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

  const createComponent = () => {
    wrapper = shallowMount(DiscussionFilterNote, {
      stubs: {
        GlSprintf,
      },
    });
  };

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

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

  it('timelineContent renders a string containing instruction for switching feed type', () => {
    expect(wrapper.find('[data-testid="discussion-filter-timeline-content"]').html()).toBe(
      '<div data-testid="discussion-filter-timeline-content">You\'re only seeing <b>other activity</b> in the feed. To add a comment, switch to one of the following options.</div>',
    );
  });

  it('emits `dropdownSelect` event with 0 parameter on clicking Show all activity button', () => {
    jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
    wrapper
      .findAll(GlButton)
      .at(0)
      .vm.$emit('click');

    expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 0);
  });

  it('emits `dropdownSelect` event with 1 parameter on clicking Show comments only button', () => {
    jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
    wrapper
      .findAll(GlButton)
      .at(1)
      .vm.$emit('click');

    expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 1);
  });
});