jspurefix
Version:
pure node js fix engine
54 lines • 2.82 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");
const dictionary_1 = require("../../dictionary");
let setup;
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
setup = new setup_1.Setup('session/qf-fix44.json');
yield setup.init();
}), 45000);
const from = '461=O|55=*';
const to = '55=*|461=O';
const marketDataMsg = '8=FIX.4.4|9=0000170|35=V|49=init-comp|56=accept-comp|34=2|57=fix|52=20231108-09:40:46.257|262=1698937860913.38|263=1|264=0|267=3|269=0|269=1|269=H|146=1|461=O|55=*|10=033|';
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: '*',
CFICode: 'O'
});
});
}
test('check definitions version', () => {
expect(setup.definitions.getMajor()).toEqual(4);
expect(setup.definitions.getMinor()).toEqual(4);
expect(setup.definitions.getServicePack()).toEqual(0);
expect(setup.definitions.version).toEqual(dictionary_1.FixVersion.FIX44);
});
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-44-ascii-parser.test.js.map