UNPKG

lml-main

Version:

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

66 lines 3.12 kB
"use strict"; var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var redux_rx_http_1 = require("redux-rx-http"); var ts_utils_1 = require("@lml/ts-utils"); require("rxjs"); var actions_1 = require("../actions"); var post_job_incident_1 = require("../epics/post-job-incident"); var mocks_1 = require("../mocks"); var cosmoui_1 = require("cosmoui"); var utils_1 = require("../../utils"); describe('postJobIncidentEpic', function () { it('on successful POST, SET_JOB_INCIDENT', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var result, response, action, actions; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: result = tslib_1.__assign({}, mocks_1.mockIncident('123')); response = ts_utils_1.mockResponse(result); action = redux_rx_http_1.rxHttpSuccess(response, undefined, { jobId: '123' }, actions_1.POST_JOB_INCIDENT); return [4 /*yield*/, ts_utils_1.getEpicActions(post_job_incident_1.postJobIncidentSuccess, action)]; case 1: actions = _a.sent(); expect(actions).toMatchObject([ expect.objectContaining({ type: cosmoui_1.SHOW_NOTIFICATION, level: expect.objectContaining({ key: 'success', }), message: 'The incident has been successfully saved', }), expect.objectContaining({ type: actions_1.SET_JOB_INCIDENT, refId: '123', incident: expect.objectContaining(result), }), ]); return [2 /*return*/]; } }); }); }); it('on error PUT, SET_JOB_INCIDENT', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var action, actions; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: action = utils_1.mockErr(actions_1.POST_JOB_INCIDENT); return [4 /*yield*/, ts_utils_1.getEpicActions(post_job_incident_1.postJobIncidentError, action)]; case 1: actions = _a.sent(); expect(actions).toMatchObject([ expect.objectContaining({ type: cosmoui_1.SHOW_NOTIFICATION, level: expect.objectContaining({ key: 'error', }), message: 'There was a problem saving the job exception. Please refresh', }), ]); return [2 /*return*/]; } }); }); }); }); //# sourceMappingURL=post-job-incident.epic.spec.js.map