aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-16 08:31:39 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-16 08:31:39 +0800
commit1c87e5f69809954add5e76de520e8ef4f405c1c0 (patch)
treef3c5dbb8cfb13d06822fb26dd6bbfbaa411ed853 /packages/connect
parentc325d638c98a990f2d0e991f2e03287183ba292f (diff)
downloaddexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.tar
dexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.tar.gz
dexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.tar.bz2
dexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.tar.lz
dexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.tar.xz
dexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.tar.zst
dexon-sol-tools-1c87e5f69809954add5e76de520e8ef4f405c1c0.zip
Get orders async tests passing
Diffstat (limited to 'packages/connect')
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts2
-rw-r--r--packages/connect/src/utils/type_converters.ts7
-rw-r--r--packages/connect/test/http_client_test.ts2
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);