lml-main
Version:
This is now a mono repository published into many standalone packages.
82 lines • 3.72 kB
JavaScript
;
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 fetch_courier_callsigns_1 = require("../epics/fetch-courier-callsigns");
var cosmoui_1 = require("cosmoui");
var utils_1 = require("../../utils");
describe('fetchCourierCallsignsEpic', function () {
it('on successful FETCH, SET_COURIER_CALLSIGNS', 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 = {
courierAssignments: {
abc: {
assignedAt: '',
callsign: 'BRUNO',
courier: {
refId: '123',
},
refId: '123',
serviceCentre: {
refId: '123',
},
},
def: {
assignedAt: '',
callsign: 'SUKI',
courier: {
refId: '123',
},
refId: '123',
serviceCentre: {
refId: '123',
},
},
},
};
response = ts_utils_1.mockResponse(result);
action = redux_rx_http_1.rxHttpSuccess(response, undefined, {}, actions_1.FETCH_COURIER_CALLSIGNS);
return [4 /*yield*/, ts_utils_1.getEpicActions(fetch_courier_callsigns_1.fetchCourierCallsignSuccess, action)];
case 1:
actions = _a.sent();
expect(actions).toMatchObject([
expect.objectContaining({
type: actions_1.SET_COURIER_CALLSIGNS,
callsigns: { BRUNO: 'abc', SUKI: 'def' },
}),
]);
return [2 /*return*/];
}
});
}); });
it('on error FETCH, FETCH_COURIER_CALLSIGNS', 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_COURIER_CALLSIGNS);
return [4 /*yield*/, ts_utils_1.getEpicActions(fetch_courier_callsigns_1.fetchCourierCallsignError, action)];
case 1:
actions = _a.sent();
expect(actions).toMatchObject([
expect.objectContaining({
type: cosmoui_1.SHOW_NOTIFICATION,
level: expect.objectContaining({
key: 'error',
}),
message: 'Failed to find a courier with the callsign ',
}),
]);
return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=fetch-courier-callsigns.epic.spec.js.map