debian-mirror-gitlab/spec/frontend/sidebar/track_invite_members_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-09-04 01:27:46 +05:30
import $ from 'jquery';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import trackShowInviteMemberLink from '~/sidebar/track_invite_members';
describe('Track user dropdown open', () => {
let trackingSpy;
let dropdownElement;
beforeEach(() => {
document.body.innerHTML = `
<div id="dummy-wrapper-element">
<div class="js-sidebar-assignee-dropdown">
2021-11-11 11:23:49 +05:30
<div class="js-invite-members-track" data-track-action="_track_event_" data-track-label="_track_label_">
2021-09-04 01:27:46 +05:30
</div>
</div>
</div>
`;
dropdownElement = document.querySelector('.js-sidebar-assignee-dropdown');
trackingSpy = mockTracking('_category_', dropdownElement, jest.spyOn);
document.body.dataset.page = 'some:page';
trackShowInviteMemberLink(dropdownElement);
});
afterEach(() => {
unmockTracking();
});
it('sends a tracking event when the dropdown is opened and contains Invite Members link', () => {
$(dropdownElement).trigger('shown.bs.dropdown');
expect(trackingSpy).toHaveBeenCalledWith(undefined, '_track_event_', {
label: '_track_label_',
});
});
});