jspurefix
Version:
pure node js fix engine
47 lines • 2.51 kB
JavaScript
;
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 setup_1 = require("../env/setup");
let setup;
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
setup = new setup_1.Setup('session/test-qf50sp2-initiator.json');
yield setup.init();
}), 45000);
const from = '55=GBPUSD|461=0';
const to = '461=0|55=GBPUSD';
const marketDataMsg = `8=FIX.5.0SP2|9=0000145|35=V|49=init-comp|56=accept-comp|34=2|57=fix|52=20231108-20:13:54.831|262=#GBPUSD#0#|263=1|264=0|267=3|269=0|269=1|269=H|146=1|${from}|10=109|`;
function checkMessage(txt) {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
const res = yield setup.client.parseText(txt);
expect(res.view).toBeTruthy();
const o = (_a = res.view) === null || _a === void 0 ? void 0 : _a.toObject();
expect(o).toBeTruthy();
expect(o.InstrmtMDReqGrp).toBeTruthy();
expect((_b = o.InstrmtMDReqGrp) === null || _b === void 0 ? void 0 : _b.NoRelatedSym).toBeTruthy();
const grp = (_d = (_c = o.InstrmtMDReqGrp) === null || _c === void 0 ? void 0 : _c.NoRelatedSym) !== null && _d !== void 0 ? _d : [];
expect(grp.length).toEqual(1);
expect(grp[0].Instrument).toEqual({
Symbol: 'GBPUSD',
CFICode: '0'
});
});
}
test(`parse MD request with instrument ${from}`, () => __awaiter(void 0, void 0, void 0, function* () {
yield checkMessage(marketDataMsg);
}));
test(`parse MD request with instrument ${to}`, () => __awaiter(void 0, void 0, void 0, function* () {
const marketDataMsg2 = marketDataMsg.replace(from, to);
expect(marketDataMsg).not.toEqual(marketDataMsg2);
yield checkMessage(marketDataMsg2);
}));
//# sourceMappingURL=qf-50sp2-ascii-parser.test.js.map