debian-mirror-gitlab/spec/frontend/notes/components/discussion_jump_to_next_button_spec.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-07-07 11:18:12 +05:30
import { shallowMount } from '@vue/test-utils';
2020-01-01 13:55:28 +05:30
import JumpToNextDiscussionButton from '~/notes/components/discussion_jump_to_next_button.vue';
2020-04-08 14:13:33 +05:30
import { mockTracking } from '../../helpers/tracking_helper';
2019-07-07 11:18:12 +05:30
describe('JumpToNextDiscussionButton', () => {
2020-04-08 14:13:33 +05:30
const fromDiscussionId = 'abc123';
2019-07-07 11:18:12 +05:30
let wrapper;
2020-04-08 14:13:33 +05:30
let trackingSpy;
let jumpFn;
2019-07-07 11:18:12 +05:30
beforeEach(() => {
2020-04-08 14:13:33 +05:30
jumpFn = jest.fn();
wrapper = shallowMount(JumpToNextDiscussionButton, {
propsData: { fromDiscussionId },
});
wrapper.setMethods({ jumpToNextRelativeDiscussion: jumpFn });
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
2019-07-07 11:18:12 +05:30
});
afterEach(() => {
wrapper.destroy();
});
it('matches the snapshot', () => {
expect(wrapper.vm.$el).toMatchSnapshot();
});
2020-04-08 14:13:33 +05:30
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',
});
});
2019-07-07 11:18:12 +05:30
});