debian-mirror-gitlab/spec/frontend/wikis_spec.js

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

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-07-28 23:09:34 +05:30
import { escape } from 'lodash';
2022-07-16 23:28:13 +05:30
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
2020-06-23 00:09:42 +05:30
import Wikis from '~/pages/shared/wikis/wikis';
2020-07-28 23:09:34 +05:30
import Tracking from '~/tracking';
2019-12-04 20:38:33 +05:30
describe('Wikis', () => {
2020-07-28 23:09:34 +05:30
describe('trackPageView', () => {
const trackingPage = 'projects:wikis:show';
const trackingContext = { foo: 'bar' };
const showPageHtmlFixture = `
<div class="js-wiki-page-content" data-tracking-context="${escape(
JSON.stringify(trackingContext),
)}"></div>
`;
beforeEach(() => {
setHTMLFixture(showPageHtmlFixture);
document.body.dataset.page = trackingPage;
jest.spyOn(Tracking, 'event').mockImplementation();
Wikis.trackPageView();
});
2022-07-16 23:28:13 +05:30
afterEach(() => {
resetHTMLFixture();
});
2020-07-28 23:09:34 +05:30
it('sends the tracking event and context', () => {
expect(Tracking.event).toHaveBeenCalledWith(trackingPage, 'view_wiki_page', {
label: 'view_wiki_page',
context: {
2021-01-03 14:25:43 +05:30
schema: 'iglu:com.gitlab/wiki_page_context/jsonschema/1-0-1',
2020-07-28 23:09:34 +05:30
data: trackingContext,
},
});
});
});
2019-12-04 20:38:33 +05:30
});