aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/test
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-15 05:59:53 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-15 07:06:09 +0800
commit5c40c466f6e9f690afa86f23dd5ba240691dceb8 (patch)
treec7eda62370f6dff4f4fd253dc1484705ea6f3cb9 /packages/connect/test
parentce88086e080e05ed71c1ef4e31f2d0ce530af67f (diff)
downloaddexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.gz
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.bz2
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.lz
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.xz
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.tar.zst
dexon-sol-tools-5c40c466f6e9f690afa86f23dd5ba240691dceb8.zip
Update json-schemas, update HTTPClient types
Diffstat (limited to 'packages/connect/test')
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts4
-rw-r--r--packages/connect/test/http_client_test.ts4
-rw-r--r--packages/connect/test/orderbook_channel_message_parsers_test.ts20
3 files changed, 14 insertions, 14 deletions
diff --git a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts
index 1225ac4fc..03cce8444 100644
--- a/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts
+++ b/packages/connect/test/fixtures/standard_relayer_api/token_pairs.ts
@@ -1,8 +1,8 @@
import { BigNumber } from '@0xproject/utils';
-import { TokenPairsItem } from '../../../src/types';
+import { AssetPairsItem } from '../../../src/types';
-export const assetDataPairsResponse: TokenPairsItem[] = [
+export const assetDataPairsResponse: AssetPairsItem[] = [
{
assetDataA: {
address: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index ea5717327..866cf7b2f 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -7,6 +7,8 @@ import 'mocha';
import { HttpClient } from '../src/index';
+import { assetDataPairsResponse } from './fixtures/standard_relayer_api/assetData_pairs';
+import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/assetData_pairs.json';
import { feesResponse } from './fixtures/standard_relayer_api/fees';
import * as feesResponseJSON from './fixtures/standard_relayer_api/fees.json';
import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
@@ -15,8 +17,6 @@ import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json';
import { ordersResponse } from './fixtures/standard_relayer_api/orders';
import * as ordersResponseJSON from './fixtures/standard_relayer_api/orders.json';
-import { assetDataPairsResponse } from './fixtures/standard_relayer_api/assetData_pairs';
-import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/assetData_pairs.json';
chai.config.includeStack = true;
chai.use(dirtyChai);
diff --git a/packages/connect/test/orderbook_channel_message_parsers_test.ts b/packages/connect/test/orderbook_channel_message_parsers_test.ts
index ce881e627..9960ad1df 100644
--- a/packages/connect/test/orderbook_channel_message_parsers_test.ts
+++ b/packages/connect/test/orderbook_channel_message_parsers_test.ts
@@ -2,7 +2,7 @@ import * as chai from 'chai';
import * as dirtyChai from 'dirty-chai';
import 'mocha';
-import { orderbookChannelMessageParser } from '../src/utils/orderbook_channel_message_parser';
+import { ordersChannelMessageParser } from '../src/utils/orderbook_channel_message_parser';
import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
@@ -20,20 +20,20 @@ chai.config.includeStack = true;
chai.use(dirtyChai);
const expect = chai.expect;
-describe('orderbookChannelMessageParser', () => {
+describe('ordersChannelMessageParser', () => {
describe('#parser', () => {
it('parses snapshot messages', () => {
- const snapshotMessage = orderbookChannelMessageParser.parse(snapshotOrdersChannelMessage);
+ const snapshotMessage = ordersChannelMessageParser.parse(snapshotOrdersChannelMessage);
expect(snapshotMessage.type).to.be.equal('snapshot');
expect(snapshotMessage.payload).to.be.deep.equal(orderbookResponse);
});
it('parses update messages', () => {
- const updateMessage = orderbookChannelMessageParser.parse(updateOrdersChannelMessage);
+ const updateMessage = ordersChannelMessageParser.parse(updateOrdersChannelMessage);
expect(updateMessage.type).to.be.equal('update');
expect(updateMessage.payload).to.be.deep.equal(orderResponse);
});
it('returns unknown message for messages with unsupported types', () => {
- const unknownMessage = orderbookChannelMessageParser.parse(unknownOrdersChannelMessage);
+ const unknownMessage = ordersChannelMessageParser.parse(unknownOrdersChannelMessage);
expect(unknownMessage.type).to.be.equal('unknown');
expect(unknownMessage.payload).to.be.undefined();
});
@@ -43,7 +43,7 @@ describe('orderbookChannelMessageParser', () => {
"requestId": 1,
"payload": {}
}`;
- const badCall = () => orderbookChannelMessageParser.parse(typelessMessage);
+ const badCall = () => ordersChannelMessageParser.parse(typelessMessage);
expect(badCall).throws(`Message is missing a type parameter: ${typelessMessage}`);
});
it('throws when type is not a string', () => {
@@ -53,23 +53,23 @@ describe('orderbookChannelMessageParser', () => {
"requestId": 1,
"payload": {}
}`;
- const badCall = () => orderbookChannelMessageParser.parse(messageWithBadType);
+ const badCall = () => ordersChannelMessageParser.parse(messageWithBadType);
expect(badCall).throws('Expected type to be of type string, encountered: 1');
});
it('throws when snapshot message has malformed payload', () => {
- const badCall = () => orderbookChannelMessageParser.parse(malformedSnapshotOrdersChannelMessage);
+ const badCall = () => ordersChannelMessageParser.parse(malformedSnapshotOrdersChannelMessage);
// tslint:disable-next-line:max-line-length
const errMsg =
'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"';
expect(badCall).throws(errMsg);
});
it('throws when update message has malformed payload', () => {
- const badCall = () => orderbookChannelMessageParser.parse(malformedUpdateOrdersChannelMessage);
+ const badCall = () => ordersChannelMessageParser.parse(malformedUpdateOrdersChannelMessage);
expect(badCall).throws(/^Expected message to conform to schema/);
});
it('throws when input message is not valid JSON', () => {
const nonJsonString = 'h93b{sdfs9fsd f';
- const badCall = () => orderbookChannelMessageParser.parse(nonJsonString);
+ const badCall = () => ordersChannelMessageParser.parse(nonJsonString);
expect(badCall).throws('Unexpected assetData h in JSON at position 0');
});
});