@aller/blink
Version:
A library for tracking user behaviour.
76 lines • 2.85 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var screen_1 = __importDefault(require("../screen"));
var actions_1 = require("../../actions");
describe('screen reducer', function () {
describe('SCREEN_SHOW', function () {
it('should have correct default state', function () {
var action = {
type: 'INVALID_ACTION',
};
expect(screen_1.default(undefined, action)).toEqual({
events: [],
});
});
it('should add a screen show event to empty state', function () {
var action = { type: actions_1.SCREEN_SHOW, payload: { time: new Date(5) } };
expect(screen_1.default({ events: [] }, action)).toEqual({
events: [
{
time: new Date(5),
type: 'show',
},
],
});
});
it('should add a screen show event to existing state', function () {
var action = { type: actions_1.SCREEN_SHOW, payload: { time: new Date(5) } };
expect(screen_1.default({
events: [{ time: new Date(3), type: 'hide' }],
}, action)).toEqual({
events: [
{
time: new Date(3),
type: 'hide',
},
{
time: new Date(5),
type: 'show',
},
],
});
});
});
describe('SCREEN_HIDE', function () {
it('should add a screen show event to empty state', function () {
var action = { type: actions_1.SCREEN_HIDE, payload: { time: new Date(5) } };
expect(screen_1.default({ events: [] }, action)).toEqual({
events: [
{
time: new Date(5),
type: 'hide',
},
],
});
});
it('should add a screen show event to existing state', function () {
var action = { type: actions_1.SCREEN_HIDE, payload: { time: new Date(5) } };
expect(screen_1.default({ events: [{ time: new Date(3), type: 'hide' }] }, action)).toEqual({
events: [
{
time: new Date(3),
type: 'hide',
},
{
time: new Date(5),
type: 'hide',
},
],
});
});
});
});
//# sourceMappingURL=screen.test.js.map
;