Update orderbook channel and factory tests
This commit is contained in:
@@ -9,18 +9,38 @@ import { orderbookChannelFactory } from '../src/orderbook_channel_factory';
|
||||
chai.config.includeStack = true;
|
||||
chai.use(dirtyChai);
|
||||
const expect = chai.expect;
|
||||
const emptyOrderbookChannelHandler = {
|
||||
onSnapshot: () => {
|
||||
_.noop();
|
||||
},
|
||||
onUpdate: () => {
|
||||
_.noop();
|
||||
},
|
||||
onError: () => {
|
||||
_.noop();
|
||||
},
|
||||
onClose: () => {
|
||||
_.noop();
|
||||
},
|
||||
};
|
||||
|
||||
describe('orderbookChannelFactory', () => {
|
||||
const websocketUrl = 'ws://localhost:8080';
|
||||
|
||||
describe('#createWebSocketOrderbookChannelAsync', () => {
|
||||
it('throws when input is not a url', () => {
|
||||
const badInput = 54;
|
||||
const badSubscribeCall = orderbookChannelFactory.createWebSocketOrderbookChannelAsync.bind(
|
||||
orderbookChannelFactory,
|
||||
badInput,
|
||||
);
|
||||
expect(orderbookChannelFactory.createWebSocketOrderbookChannelAsync(badInput as any)).to.be.rejected();
|
||||
const badUrlInput = 54;
|
||||
expect(
|
||||
orderbookChannelFactory.createWebSocketOrderbookChannelAsync(
|
||||
badUrlInput as any,
|
||||
emptyOrderbookChannelHandler,
|
||||
),
|
||||
).to.be.rejected();
|
||||
});
|
||||
it('throws when handler has the incorrect members', () => {
|
||||
const badHandlerInput = {};
|
||||
expect(
|
||||
orderbookChannelFactory.createWebSocketOrderbookChannelAsync(websocketUrl, badHandlerInput as any),
|
||||
).to.be.rejected();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user