Repository URL to install this package:
|
Version:
1.4.3 ▾
|
"use strict";
var _getBasicAnalyticsData = _interopRequireDefault(require("./getBasicAnalyticsData"));
var _getSystemType = _interopRequireDefault(require("./getSystemType"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
jest.mock('./getSystemType');
describe('getBasicAnalyticsData', function () {
beforeEach(function () {
window.innerHeight = 123;
window.innerWidth = 42;
});
it('contains the specified `pageType`', function () {
var data = (0, _getBasicAnalyticsData.default)({
pageType: 'a fancy page type'
});
expect(data).toMatchObject({
page: {
pageType: 'a fancy page type'
}
});
});
it('contains the viewport dimensions (height and width)', function () {
var data = (0, _getBasicAnalyticsData.default)({});
expect(data).toMatchObject({
page: {
viewportHeight: 123,
viewportWidth: 42
}
});
});
it('contains `0` as viewport dimensions if they are not set on the window', function () {
window.innerHeight = undefined;
window.innerWidth = undefined;
var data = (0, _getBasicAnalyticsData.default)({});
expect(data).toMatchObject({
page: {
viewportHeight: 0,
viewportWidth: 0
}
});
});
it('contains the system type', function () {
_getSystemType.default.mockReturnValueOnce('some system type');
var data = (0, _getBasicAnalyticsData.default)({});
expect(data).toMatchObject({
environment: {
systemType: 'some system type'
}
});
});
it('passes the specified `NODE_ENV` and `DOODLE_ENV` when determining the system type', function () {
var envs = {
NODE_ENV: 'test',
DOODLE_ENV: 'party'
};
var data = (0, _getBasicAnalyticsData.default)(envs);
expect(_getSystemType.default).toHaveBeenLastCalledWith(envs);
});
});