UNPKG

lml-main

Version:

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

88 lines 3.5 kB
"use strict"; var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); require("rxjs"); var mocks_1 = require("../mocks"); var ts_utils_1 = require("@lml/ts-utils"); var redux_rx_http_1 = require("redux-rx-http"); var actions_1 = require("../actions"); var post_allocation_1 = require("../epics/post-allocation"); var cosmoui_1 = require("cosmoui"); describe('Allocation epics', function () { it('should call set allocation batch action when post allocation is successful', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var allocation, response, action, actions; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: allocation = mocks_1.mockAllocation(); response = ts_utils_1.mockResponse(allocation); action = redux_rx_http_1.rxHttpSuccess(response, undefined, {}, actions_1.POST_ALLOCATION); return [4 /*yield*/, ts_utils_1.getEpicActions(post_allocation_1.postAllocationSuccess, action)]; case 1: actions = _a.sent(); expect(actions).toMatchObject([ expect.objectContaining({ type: actions_1.SET_ALLOCATION_BY_ID, allocation: allocation, }), expect.objectContaining({ type: cosmoui_1.SHOW_NOTIFICATION, }), ]); return [2 /*return*/]; } }); }); }); // it('should call set allocation batch action when post batch allocation is successful', async () => { // const allocations = createArray(mockAllocationGroup() // const response = mockResponse(allocations) // const action = rxHttpSuccess( // response, // undefined, // {}, // POST_ALLOCATION_GROUP, // ) // const actions = await getEpicActions(postAllocationGroupSuccess, action) // expect(actions).toMatchObject([ // expect.objectContaining({ // type: SET_ALLOCATION_GROUP_BY_ID, // allocationGroup: allocations, // }), // ]) // }) // it('should only set allocation jobs that are not erroneous', async () => { // const allocation = { // ...mockAllocationGroup(), // jobs: [{ // refId: 'goodRefId', // }, { // refId: 'badRefId', // }], // errors: [{ // refId: 'badRefId', // }], // } // const result = { // ...allocation, // jobs: [{ // refId: 'goodRefId', // }], // } // const response = mockResponse(allocation) // const action = rxHttpSuccess( // response, // undefined, // {}, // POST_ALLOCATION_GROUP, // ) // const actions = await getEpicActions(postAllocationGroupSuccess, action) // expect(actions).toMatchObject([ // expect.objectContaining({ // type: SET_ALLOCATION_GROUP_BY_ID, // allocationBatch: result, // }), // ]) // }) }); //# sourceMappingURL=epic.spec.js.map