UNPKG

jspurefix

Version:
84 lines 5.12 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); const index_1 = require("../../index"); const setup_1 = require("../env/setup"); const logon = '8=FIX4.4|9=0000208|35=A|49=sender-10|56=target-20|34=1|57=sub-a|52=20180610-10:39:01.621|98=2|108=62441|95=20|96=VgfoSqo56NqSVI1fLdlI|141=Y|789=4886|383=20|384=1|372=ipsum|385=R|464=N|553=sit|554=consectetur|10=49|'; let setup; beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { setup = new setup_1.Setup(); yield setup.init(); }), 45000); test('0 gaps', () => __awaiter(void 0, void 0, void 0, function* () { var _a, _b, _c; const res = yield setup.client.parseText(logon); expect(res.event).toEqual('msg'); expect(res.msgType).toEqual(index_1.MsgType.Logon); const unknowns = (_b = (_a = res.view) === null || _a === void 0 ? void 0 : _a.structure) === null || _b === void 0 ? void 0 : _b.layout['.undefined']; expect(unknowns).toBeFalsy(); const o = (_c = res === null || res === void 0 ? void 0 : res.view) === null || _c === void 0 ? void 0 : _c.toObject(); expect(o).toBeTruthy(); expect(o.Password).toEqual('consectetur'); expect(o.Username).toEqual('sit'); })); test('1 gap', () => __awaiter(void 0, void 0, void 0, function* () { var _d, _e, _f; const gap = logon.replace('108=62441|', '108=62441|9999=im not here'); const res = yield setup.client.parseText(gap); expect(res.event).toEqual('msg'); expect(res.msgType).toEqual(index_1.MsgType.Logon); const unknown = (_e = (_d = res === null || res === void 0 ? void 0 : res.view) === null || _d === void 0 ? void 0 : _d.structure) === null || _e === void 0 ? void 0 : _e.layout['.undefined']; expect(unknown).toBeTruthy(); expect(unknown.startTag).toEqual(9999); expect(unknown.startPosition).toEqual(10); const o = (_f = res === null || res === void 0 ? void 0 : res.view) === null || _f === void 0 ? void 0 : _f.toObject(); expect(o).toBeTruthy(); expect(o.Password).toEqual('consectetur'); expect(o.Username).toEqual('sit'); })); test('1 gap next to 1 gap', () => __awaiter(void 0, void 0, void 0, function* () { var _g, _h, _j; const gap = logon.replace('108=62441|', '108=62441|1=gap|2=gap|'); const res = yield setup.client.parseText(gap); expect(res.event).toEqual('msg'); expect(res.msgType).toEqual(index_1.MsgType.Logon); const unknowns = (_h = (_g = res === null || res === void 0 ? void 0 : res.view) === null || _g === void 0 ? void 0 : _g.structure) === null || _h === void 0 ? void 0 : _h.layout['.undefined']; expect(unknowns).toBeTruthy(); expect(Array.isArray(unknowns)).toEqual(true); expect(unknowns[0].startTag).toEqual(1); expect(unknowns[0].startPosition).toEqual(10); expect(unknowns[1].startTag).toEqual(2); expect(unknowns[1].startPosition).toEqual(11); const o = (_j = res === null || res === void 0 ? void 0 : res.view) === null || _j === void 0 ? void 0 : _j.toObject(); expect(o).toBeTruthy(); expect(o.Password).toEqual('consectetur'); expect(o.Username).toEqual('sit'); })); test('1 gap undefined msg', () => __awaiter(void 0, void 0, void 0, function* () { var _k, _l; const gap = logon.replace('108=62441|', '108=62441|9999=im not here'); const res = yield setup.client.parseText(gap); expect(res.event).toEqual('msg'); expect(res.msgType).toEqual(index_1.MsgType.Logon); expect((_k = res === null || res === void 0 ? void 0 : res.view) === null || _k === void 0 ? void 0 : _k.getUndefined()).toBeTruthy(); expect((_l = res === null || res === void 0 ? void 0 : res.view) === null || _l === void 0 ? void 0 : _l.undefinedForMsg()).toEqual('undefined tag = 9999'); })); test('2 gap undefined msg', () => __awaiter(void 0, void 0, void 0, function* () { var _m, _o; const gap = logon.replace('108=62441|', '108=62441|1=gap|2=gap|'); const res = yield setup.client.parseText(gap); expect(res.event).toEqual('msg'); expect(res.msgType).toEqual(index_1.MsgType.Logon); expect((_m = res === null || res === void 0 ? void 0 : res.view) === null || _m === void 0 ? void 0 : _m.getUndefined()).toBeTruthy(); expect((_o = res === null || res === void 0 ? void 0 : res.view) === null || _o === void 0 ? void 0 : _o.undefinedForMsg()).toEqual('undefined tags = 1, 2'); })); //# sourceMappingURL=ascii-segment.test.js.map