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

discussion_jump_to_next_button_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: 183966cf4357cd33d8f2f8b604ecf404c943503c (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
import { shallowMount } from '@vue/test-utils';
import JumpToNextDiscussionButton from '~/notes/components/discussion_jump_to_next_button.vue';
import { mockTracking } from '../../helpers/tracking_helper';

describe('JumpToNextDiscussionButton', () => {
  const fromDiscussionId = 'abc123';
  let wrapper;
  let trackingSpy;
  let jumpFn;

  beforeEach(() => {
    jumpFn = jest.fn();
    wrapper = shallowMount(JumpToNextDiscussionButton, {
      propsData: { fromDiscussionId },
    });
    wrapper.setMethods({ jumpToNextRelativeDiscussion: jumpFn });

    trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
  });

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

  it('matches the snapshot', () => {
    expect(wrapper.vm.$el).toMatchSnapshot();
  });

  it('calls jumpToNextRelativeDiscussion when clicked', () => {
    wrapper.find({ ref: 'button' }).trigger('click');

    expect(jumpFn).toHaveBeenCalledWith(fromDiscussionId);
  });

  it('sends the correct tracking event when clicked', () => {
    wrapper.find({ ref: 'button' }).trigger('click');

    expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', {
      label: 'mr_next_unresolved_thread',
      property: 'click_next_unresolved_thread',
    });
  });
});