UNPKG

jspurefix

Version:
76 lines 4.55 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 path = require("path"); const util_1 = require("../../util"); const index_1 = require("../../index"); const setup_1 = require("../env/setup"); const helper_fn_tst_1 = require("../env/helper-fn.tst"); let definitions; let jsonHelper; let config; const root = path.join(__dirname, '../../../data/examples/FIX.4.4/quickfix'); let setup; beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { setup = new setup_1.Setup('session/qf-fix44.json', null); yield setup.init(); definitions = setup.definitions; jsonHelper = new util_1.JsonHelper(definitions); config = setup.clientConfig; }), 45000); test('test logon JSON => object => fix => object', () => __awaiter(void 0, void 0, void 0, function* () { const msgType = index_1.MsgType.Logon; const file = path.join(root, 'logon/object.json'); const msg = jsonHelper.fromJson(file, msgType); yield expect((0, helper_fn_tst_1.testEncodeDecode)(config, msgType, msg)).resolves.toEqual(msg); }), 1000); test('test execution report JSON => object => fix => object', () => __awaiter(void 0, void 0, void 0, function* () { const msgType = index_1.MsgType.ExecutionReport; const file = path.join(root, 'execution-report/object.json'); const msg = jsonHelper.fromJson(file, msgType); yield expect((0, helper_fn_tst_1.testEncodeDecode)(config, msgType, msg)).resolves.toEqual(msg); }), 2000); test('test execution2 report JSON => object => fix => object', () => __awaiter(void 0, void 0, void 0, function* () { const msgType = index_1.MsgType.ExecutionReport; const file = path.join(root, 'execution-report2/object.json'); const msg = jsonHelper.fromJson(file, msgType); yield expect((0, helper_fn_tst_1.testEncodeDecode)(config, msgType, msg)).resolves.toEqual(msg); }), 2000); test('test order cxl reject JSON => object => fix => object', () => __awaiter(void 0, void 0, void 0, function* () { const msgType = index_1.MsgType.OrderCancelReject; const file = path.join(root, 'order-cancel-reject/object.json'); const msg = jsonHelper.fromJson(file, msgType); yield expect((0, helper_fn_tst_1.testEncodeDecode)(config, msgType, msg)).resolves.toEqual(msg); }), 1000); test('test quote request JSON => object => fix => object', () => __awaiter(void 0, void 0, void 0, function* () { const msgType = index_1.MsgType.QuoteRequest; const file = path.join(root, 'quote-request/object.json'); const msg = jsonHelper.fromJson(file, msgType); yield expect((0, helper_fn_tst_1.testEncodeDecode)(config, msgType, msg)).resolves.toEqual(msg); }), 1000); test('test md request JSON => object => fix => object', () => __awaiter(void 0, void 0, void 0, function* () { const msgType = index_1.MsgType.MarketDataSnapshotFullRefresh; const file = path.join(root, 'md-data-snapshot/object.json'); const msg = jsonHelper.fromJson(file, msgType); yield expect((0, helper_fn_tst_1.testEncodeDecode)(config, msgType, msg)).resolves.toEqual(msg); }), 1000); test('parse MD snapshot msg', () => __awaiter(void 0, void 0, void 0, function* () { var _a; const msg = '8=FIX.4.4|9=224|35=W|34=8|49=TEST|56=TEST|52=20220621-17:16:16.414|262=#GBPUSD#0#|55=GBPUSD|268=3|269=0|270=1.22759|271=1|63=0|272=20220623|768=0|269=1|270=1.22759|271=1|63=0|272=20220623|768=0|269=H|270=1.22759|63=0|272=20220623|768=0|10=066|'; const res = yield setup.client.parseText(msg); expect(res.event).toEqual('msg'); expect(res.msgType).toEqual(index_1.MsgType.MarketDataSnapshotFullRefresh); const v2 = (_a = res.view) === null || _a === void 0 ? void 0 : _a.getView('MDFullGrp'); const o = v2 === null || v2 === void 0 ? void 0 : v2.toObject(); expect(o).toBeTruthy(); })); //# sourceMappingURL=qf-full-msg.test.js.map