Repository URL to install this package:
|
Version:
1.0.0-alpha.7 ▾
|
import { getBasicAnalyticsData } from './getBasicAnalyticsData';
import { getSystemType } from './getSystemType';
jest.mock('./getSystemType');
describe('getBasicAnalyticsData', () => {
beforeEach(() => {
window.innerHeight = 600;
window.innerWidth = 800;
});
it('contains the specified `pageType`', () => {
const data = getBasicAnalyticsData({ pageType: 'a fancy page type' });
expect(data).toMatchObject({
page: {
pageType: 'a fancy page type',
},
});
});
it('contains the viewport dimensions (height and width)', () => {
const data = getBasicAnalyticsData();
expect(data).toMatchObject({
page: {
viewportHeight: 600,
viewportWidth: 800,
},
});
});
it('contains `0` as viewport dimensions if they are not set on the window', () => {
window.innerHeight = undefined;
window.innerWidth = undefined;
const data = getBasicAnalyticsData();
expect(data).toMatchObject({
page: {
viewportHeight: 0,
viewportWidth: 0,
},
});
});
it('contains the system type', () => {
getSystemType.mockReturnValueOnce('some system type');
const data = getBasicAnalyticsData();
expect(data).toMatchObject({
environment: {
systemType: 'some system type',
},
});
});
});