UNPKG

lml-main

Version:

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

112 lines 5.68 kB
"use strict"; var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); require("rxjs"); var redux_rx_http_1 = require("redux-rx-http"); var ts_utils_1 = require("@lml/ts-utils"); var actions_1 = require("../actions"); var mocks_1 = require("../mocks"); var get_location_by_id_1 = require("../epics/get-location-by-id"); var cosmoui_1 = require("cosmoui"); var utils_1 = require("../../utils"); describe('Locations epic', function () { describe('getLocationByIdSuccess', function () { it('on successful FETCH, FETCH_LOCATION_BY_OBJECT_ID', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var location, response, action, expectedActions, actions; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: location = tslib_1.__assign({}, mocks_1.mockLocation()); response = ts_utils_1.mockResponse(location); action = redux_rx_http_1.rxHttpSuccess(response, undefined, {}, actions_1.FETCH_LOCATION_BY_OBJECT_ID); expectedActions = [ { type: actions_1.SET_LOCATION_BY_OBJECT_ID, location: location, }, ]; return [4 /*yield*/, ts_utils_1.getEpicActions(get_location_by_id_1.getLocationByIdSuccess, action)]; case 1: actions = _a.sent(); expect(actions).toEqual(expectedActions); return [2 /*return*/]; } }); }); }); }); describe('getLocationByIdBatchSuccess', function () { it('on successful FETCH, FETCH_LOCATION_BY_OBJECT_ID_BATCH', function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { var locations, response, action, expectedActions, actions; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: locations = [ mocks_1.mockLocation(), mocks_1.mockLocation(), ]; response = ts_utils_1.mockResponse({ locations: locations }); action = redux_rx_http_1.rxHttpSuccess(response, undefined, {}, actions_1.FETCH_LOCATION_BY_OBJECT_ID_BATCH); expectedActions = [ { type: actions_1.SET_LOCATION_BY_OBJECT_ID_BATCH, locations: locations, }, ]; return [4 /*yield*/, ts_utils_1.getEpicActions(get_location_by_id_1.getLocationByIdBatchSuccess, action)]; case 1: actions = _a.sent(); expect(actions).toEqual(expectedActions); return [2 /*return*/]; } }); }); }); }); describe('getLocationByIdError', function () { it('on error FETCH, FETCH_LOCATION_BY_OBJECT_ID', 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.FETCH_LOCATION_BY_OBJECT_ID); return [4 /*yield*/, ts_utils_1.getEpicActions(get_location_by_id_1.getLocationByIdError, 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 fetching location data. Please refresh', }), ]); return [2 /*return*/]; } }); }); }); it('on error FETCH, FETCH_LOCATION_BY_OBJECT_ID_BATCH', 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.FETCH_LOCATION_BY_OBJECT_ID_BATCH); return [4 /*yield*/, ts_utils_1.getEpicActions(get_location_by_id_1.getLocationByIdError, 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 fetching location data. Please refresh', }), ]); return [2 /*return*/]; } }); }); }); }); }); //# sourceMappingURL=get-location-by-id.epic.spec.js.map