UNPKG

lml-main

Version:

This is now a mono repository published into many standalone packages.

46 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var reducers_1 = require("../reducers"); var actions_1 = require("../actions"); var mocks_1 = require("../mocks"); describe('Locations reducer', function () { /* * Mocks Date.now, because there is race condition * were time not always come back from reducer * */ var now = Date.now(); Date.now = jest.fn().mockReturnValue(now); test('handles setLocationByObjectId action', function () { var initialState = undefined; var location = mocks_1.mockLocation(); var action = actions_1.setLocationByObjectId(location); var resultState = { byId: (_a = {}, _a[location.objectId] = location, _a), lastLocationsUpdate: null, }; var state = reducers_1.locationApiReducer(initialState, action); expect(state).toEqual(resultState); var _a; }); test('handles setLocationByObjectIdBatch action', function () { var initialState = undefined; var locations = [ mocks_1.mockLocation(), mocks_1.mockLocation(), ]; var action = actions_1.setLocationByObjectIdBatch(locations); var resultState = { byId: (_a = {}, _a[locations[0].objectId] = locations[0], _a[locations[1].objectId] = locations[1], _a), lastLocationsUpdate: Date.now(), }; var state = reducers_1.locationApiReducer(initialState, action); expect(state).toEqual(resultState); var _a; }); }); //# sourceMappingURL=reducer.spec.js.map