2020-07-28 23:09:34 +05:30
|
|
|
import { escape } from 'lodash';
|
2021-03-08 18:12:59 +05:30
|
|
|
import { setHTMLFixture } 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();
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
});
|