UNPKG

lml-main

Version:

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

47 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var faker_1 = require("faker"); var ts_utils_1 = require("@lml/ts-utils"); var mocks_1 = require("../mocks"); var actions_1 = require("../actions"); var reducers_1 = require("../reducers"); describe('Allocation data reducer', function () { it('should save a single allocation by job id', function () { var allocation = mocks_1.mockAllocation(); var action = actions_1.setAllocationById(allocation); var state = reducers_1.allocationDataReducer(reducers_1.initialAllocationDataState, action); var res = state.byJobId[allocation.job.refId]; expect(res).toEqual(allocation); }); it('should save a batch of allocations by job id', function () { var arr = ts_utils_1.createArray(mocks_1.mockAllocation); var allocations = arr.reduce(function (map, item) { map[faker_1.random.uuid()] = item; return map; }, {}); var action = actions_1.setAllocationsByIdBatch(allocations); var state = reducers_1.allocationDataReducer(reducers_1.initialAllocationDataState, action); Object.keys(allocations).forEach(function (id) { expect(state.byJobId[id]).toEqual(allocations[id]); }); it('should save single allocation group by job id', function () { var refId = faker_1.random.uuid(); var allocation = tslib_1.__assign({}, mocks_1.mockAllocationGroup('ACTUAL'), { jobs: [ { refId: refId }, ] }); var action = actions_1.setAllocationGroupById(allocation); var state = reducers_1.allocationDataReducer(reducers_1.initialAllocationDataState, action); expect(state.byJobId[refId]).toEqual(allocation); }); }); it('should save a batch of allocation groups', function () { var refId = faker_1.random.uuid(); var allocation = mocks_1.mockAllocationGroup('ACTUAL'); var action = actions_1.setAllocationGroupByIdBatch((_a = {}, _a[refId] = allocation, _a)); var state = reducers_1.allocationDataReducer(reducers_1.initialAllocationDataState, action); expect(state.byJobId[refId]).toEqual(allocation); var _a; }); }); //# sourceMappingURL=data.reducer.spec.js.map