aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/connect/test')
-rw-r--r--packages/connect/test/orderbook_channel_factory_test.ts17
-rw-r--r--packages/connect/test/ws_orderbook_channel_test.ts18
2 files changed, 16 insertions, 19 deletions
diff --git a/packages/connect/test/orderbook_channel_factory_test.ts b/packages/connect/test/orderbook_channel_factory_test.ts
index 2ce361bd2..66394cdc9 100644
--- a/packages/connect/test/orderbook_channel_factory_test.ts
+++ b/packages/connect/test/orderbook_channel_factory_test.ts
@@ -3,15 +3,12 @@ import * as dirtyChai from 'dirty-chai';
import * as _ from 'lodash';
import 'mocha';
-import { orderbookChannelFactory } from '../src/orderbook_channel_factory';
+import { ordersChannelFactory } from '../src/orders_channel_factory';
chai.config.includeStack = true;
chai.use(dirtyChai);
const expect = chai.expect;
-const emptyOrderbookChannelHandler = {
- onSnapshot: () => {
- _.noop();
- },
+const emptyOrdersChannelHandler = {
onUpdate: () => {
_.noop();
},
@@ -23,22 +20,22 @@ const emptyOrderbookChannelHandler = {
},
};
-describe('orderbookChannelFactory', () => {
+describe('ordersChannelFactory', () => {
const websocketUrl = 'ws://localhost:8080';
- describe('#createWebSocketOrderbookChannelAsync', () => {
+ describe('#createWebSocketOrdersChannelAsync', () => {
it('throws when input is not a url', () => {
const badUrlInput = 54;
expect(
- orderbookChannelFactory.createWebSocketOrderbookChannelAsync(
+ ordersChannelFactory.createWebSocketOrdersChannelAsync(
badUrlInput as any,
- emptyOrderbookChannelHandler,
+ emptyOrdersChannelHandler,
),
).to.be.rejected();
});
it('throws when handler has the incorrect members', () => {
const badHandlerInput = {};
expect(
- orderbookChannelFactory.createWebSocketOrderbookChannelAsync(websocketUrl, badHandlerInput as any),
+ ordersChannelFactory.createWebSocketOrdersChannelAsync(websocketUrl, badHandlerInput as any),
).to.be.rejected();
});
});
diff --git a/packages/connect/test/ws_orderbook_channel_test.ts b/packages/connect/test/ws_orderbook_channel_test.ts
index b5682af36..de097c295 100644
--- a/packages/connect/test/ws_orderbook_channel_test.ts
+++ b/packages/connect/test/ws_orderbook_channel_test.ts
@@ -5,12 +5,12 @@ import 'mocha';
import * as Sinon from 'sinon';
import * as WebSocket from 'websocket';
-import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
+import { WebSocketOrdersChannel } from '../src/ws_orders_channel';
chai.config.includeStack = true;
chai.use(dirtyChai);
const expect = chai.expect;
-const emptyOrderbookChannelHandler = {
+const emptyOrdersChannelHandler = {
onSnapshot: () => {
_.noop();
},
@@ -25,12 +25,12 @@ const emptyOrderbookChannelHandler = {
},
};
-describe('WebSocketOrderbookChannel', () => {
+describe('WebSocketOrdersChannel', () => {
const websocketUrl = 'ws://localhost:8080';
const openClient = new WebSocket.w3cwebsocket(websocketUrl);
Sinon.stub(openClient, 'readyState').get(() => WebSocket.w3cwebsocket.OPEN);
Sinon.stub(openClient, 'send').callsFake(_.noop.bind(_));
- const openOrderbookChannel = new WebSocketOrderbookChannel(openClient, emptyOrderbookChannelHandler);
+ const openOrdersChannel = new WebSocketOrdersChannel(openClient, emptyOrdersChannelHandler);
const subscriptionOpts = {
baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
quoteAssetData: '0xef7fff64389b814a946f3e92105513705ca6b990',
@@ -39,20 +39,20 @@ describe('WebSocketOrderbookChannel', () => {
};
describe('#subscribe', () => {
it('throws when subscriptionOpts does not conform to schema', () => {
- const badSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, {});
+ const badSubscribeCall = openOrdersChannel.subscribe.bind(openOrdersChannel, {});
expect(badSubscribeCall).throws(
- 'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseAssetData", instance requires property "quoteAssetData"',
+ 'Expected subscriptionOpts to conform to schema /RelayerApiOrdersChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseAssetData", instance requires property "quoteAssetData"',
);
});
it('does not throw when inputs are of correct types', () => {
- const goodSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, subscriptionOpts);
+ const goodSubscribeCall = openOrdersChannel.subscribe.bind(openOrdersChannel, subscriptionOpts);
expect(goodSubscribeCall).to.not.throw();
});
it('throws when client is closed', () => {
const closedClient = new WebSocket.w3cwebsocket(websocketUrl);
Sinon.stub(closedClient, 'readyState').get(() => WebSocket.w3cwebsocket.CLOSED);
- const closedOrderbookChannel = new WebSocketOrderbookChannel(closedClient, emptyOrderbookChannelHandler);
- const badSubscribeCall = closedOrderbookChannel.subscribe.bind(closedOrderbookChannel, subscriptionOpts);
+ const closedOrdersChannel = new WebSocketOrdersChannel(closedClient, emptyOrdersChannelHandler);
+ const badSubscribeCall = closedOrdersChannel.subscribe.bind(closedOrdersChannel, subscriptionOpts);
expect(badSubscribeCall).throws('WebSocket connection is closed');
});
});