From 1c87e5f69809954add5e76de520e8ef4f405c1c0 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 15 Aug 2018 17:31:39 -0700 Subject: Get orders async tests passing --- packages/connect/src/utils/relayer_response_json_parsers.ts | 2 +- packages/connect/src/utils/type_converters.ts | 7 ++++++- packages/connect/test/http_client_test.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts index 37099384f..2b2e1efe7 100644 --- a/packages/connect/src/utils/relayer_response_json_parsers.ts +++ b/packages/connect/src/utils/relayer_response_json_parsers.ts @@ -26,7 +26,7 @@ export const relayerResponseJsonParsers = { }, parseAPIOrderJson(json: any): APIOrder { assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema); - return typeConverters.convertOrderStringFieldsToBigNumber(json); + return typeConverters.convertAPIOrderStringFieldsToBigNumber(json); }, parseOrderbookResponseJson(json: any): OrderbookResponse { assert.doesConformToSchema('orderBookResponse', json, schemas.relayerApiOrderbookResponseSchema); diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts index c28cba0e1..4b211a0b2 100644 --- a/packages/connect/src/utils/type_converters.ts +++ b/packages/connect/src/utils/type_converters.ts @@ -36,7 +36,12 @@ export const typeConverters = { convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any { const result = _.assign({}, obj); _.each(fields, field => { - _.update(result, field, (value: string) => new BigNumber(value)); + _.update(result, field, (value: string) => { + if (_.isUndefined(value)) { + throw new Error(`Could not find field '${field}' while converting string fields to BigNumber.`); + } + return new BigNumber(value); + }); }); return result; }, diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts index 9cdcde71e..7a1781131 100644 --- a/packages/connect/test/http_client_test.ts +++ b/packages/connect/test/http_client_test.ts @@ -78,7 +78,7 @@ describe('HttpClient', () => { page: 3, perPage: 50, }; - const urlWithQuery = `${url}?page=3&perPage=50&assetDataAddress=${assetDataAddress}`; + const urlWithQuery = `${url}?assetDataAddress=${assetDataAddress}&page=3&perPage=50`; fetchMock.get(urlWithQuery, ordersResponseJSON); const orders = await relayerClient.getOrdersAsync(ordersRequest); expect(orders).to.be.deep.equal(ordersResponse); -- cgit v1.2.3