Update tests
This commit is contained in:
parent
c500cc095f
commit
c403dcdabf
@ -9,17 +9,6 @@ import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
|
|||||||
chai.config.includeStack = true;
|
chai.config.includeStack = true;
|
||||||
chai.use(dirtyChai);
|
chai.use(dirtyChai);
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
describe('WebSocketOrderbookChannel', () => {
|
|
||||||
const websocketUrl = 'ws://localhost:8080';
|
|
||||||
const client = new WebSocket.w3cwebsocket(websocketUrl);
|
|
||||||
const orderbookChannel = new WebSocketOrderbookChannel(client);
|
|
||||||
const subscriptionOpts = {
|
|
||||||
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
|
||||||
quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
|
||||||
snapshot: true,
|
|
||||||
limit: 100,
|
|
||||||
};
|
|
||||||
const emptyOrderbookChannelHandler = {
|
const emptyOrderbookChannelHandler = {
|
||||||
onSnapshot: () => {
|
onSnapshot: () => {
|
||||||
_.noop();
|
_.noop();
|
||||||
@ -34,6 +23,17 @@ describe('WebSocketOrderbookChannel', () => {
|
|||||||
_.noop();
|
_.noop();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
describe('WebSocketOrderbookChannel', () => {
|
||||||
|
const websocketUrl = 'ws://localhost:8080';
|
||||||
|
const client = new WebSocket.w3cwebsocket(websocketUrl);
|
||||||
|
const orderbookChannel = new WebSocketOrderbookChannel(client, emptyOrderbookChannelHandler);
|
||||||
|
const subscriptionOpts = {
|
||||||
|
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
||||||
|
quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
||||||
|
snapshot: true,
|
||||||
|
limit: 100,
|
||||||
|
};
|
||||||
describe('#subscribe', () => {
|
describe('#subscribe', () => {
|
||||||
it('throws when subscriptionOpts does not conform to schema', () => {
|
it('throws when subscriptionOpts does not conform to schema', () => {
|
||||||
const badSubscribeCall = orderbookChannel.subscribe.bind(
|
const badSubscribeCall = orderbookChannel.subscribe.bind(
|
||||||
@ -45,12 +45,6 @@ describe('WebSocketOrderbookChannel', () => {
|
|||||||
'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"',
|
'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('throws when handler has the incorrect members', () => {
|
|
||||||
const badSubscribeCall = orderbookChannel.subscribe.bind(orderbookChannel, subscriptionOpts, {});
|
|
||||||
expect(badSubscribeCall).throws(
|
|
||||||
'Expected handler.onSnapshot to be of type function, encountered: undefined',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('does not throw when inputs are of correct types', () => {
|
it('does not throw when inputs are of correct types', () => {
|
||||||
const goodSubscribeCall = orderbookChannel.subscribe.bind(
|
const goodSubscribeCall = orderbookChannel.subscribe.bind(
|
||||||
orderbookChannel,
|
orderbookChannel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user