Repository URL to install this package:
|
Version:
0.6.0 ▾
|
import getBasicAnalyticsData from './getBasicAnalyticsData';
import getSystemType from './getSystemType';
jest.mock('./getSystemType');
describe('getBasicAnalyticsData', () => {
beforeEach(() => {
window.innerHeight = 123;
window.innerWidth = 42;
});
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: 123,
viewportWidth: 42,
},
});
});
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',
},
});
});
it('passes the specified `NODE_ENV` and `DOODLE_ENV` when determining the system type', () => {
const envs = { NODE_ENV: 'test', DOODLE_ENV: 'party' };
const data = getBasicAnalyticsData(envs);
expect(getSystemType).toHaveBeenLastCalledWith(envs);
});
});