diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-05-26 07:08:15 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-07-12 01:18:15 +0800 |
commit | a4b6112a311332df2c00799857463a646df78e25 (patch) | |
tree | 8fcc053b7fae56f7a69801e3c4091cda30a393ac /packages/connect/test | |
parent | 47debf0134b5864046831321b8eeeeb9aaaaf0a8 (diff) | |
download | dexon-0x-contracts-a4b6112a311332df2c00799857463a646df78e25.tar.gz dexon-0x-contracts-a4b6112a311332df2c00799857463a646df78e25.tar.zst dexon-0x-contracts-a4b6112a311332df2c00799857463a646df78e25.zip |
Consolidate back to one channel and expose only the factory
Diffstat (limited to 'packages/connect/test')
-rw-r--r-- | packages/connect/test/browser_ws_orderbook_channel_test.ts | 63 | ||||
-rw-r--r-- | packages/connect/test/orderbook_channel_factory_test.ts | 26 | ||||
-rw-r--r-- | packages/connect/test/ws_orderbook_channel_test.ts (renamed from packages/connect/test/node_ws_orderbook_channel_test.ts) | 8 |
3 files changed, 31 insertions, 66 deletions
diff --git a/packages/connect/test/browser_ws_orderbook_channel_test.ts b/packages/connect/test/browser_ws_orderbook_channel_test.ts deleted file mode 100644 index d6a7af5c0..000000000 --- a/packages/connect/test/browser_ws_orderbook_channel_test.ts +++ /dev/null @@ -1,63 +0,0 @@ -// import * as chai from 'chai'; -// import * as dirtyChai from 'dirty-chai'; -// import * as _ from 'lodash'; -// import 'mocha'; -// import * as WebSocket from 'websocket'; - -// import { BrowserWebSocketOrderbookChannel } from '../src/browser_ws_orderbook_channel'; - -// chai.config.includeStack = true; -// chai.use(dirtyChai); -// const expect = chai.expect; - -// describe('BrowserWebSocketOrderbookChannel', () => { -// const websocketUrl = 'ws://localhost:8080'; -// const client = new WebSocket.w3cwebsocket(websocketUrl); -// const orderbookChannel = new BrowserWebSocketOrderbookChannel(client); -// const subscriptionOpts = { -// baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', -// quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', -// snapshot: true, -// limit: 100, -// }; -// const emptyOrderbookChannelHandler = { -// onSnapshot: () => { -// _.noop(); -// }, -// onUpdate: () => { -// _.noop(); -// }, -// onError: () => { -// _.noop(); -// }, -// onClose: () => { -// _.noop(); -// }, -// }; -// describe('#subscribe', () => { -// it('throws when subscriptionOpts does not conform to schema', () => { -// const badSubscribeCall = orderbookChannel.subscribe.bind( -// orderbookChannel, -// {}, -// emptyOrderbookChannelHandler, -// ); -// expect(badSubscribeCall).throws( -// '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', () => { -// const goodSubscribeCall = orderbookChannel.subscribe.bind( -// orderbookChannel, -// subscriptionOpts, -// emptyOrderbookChannelHandler, -// ); -// expect(goodSubscribeCall).to.not.throw(); -// }); -// }); -// }); diff --git a/packages/connect/test/orderbook_channel_factory_test.ts b/packages/connect/test/orderbook_channel_factory_test.ts new file mode 100644 index 000000000..fd84332cc --- /dev/null +++ b/packages/connect/test/orderbook_channel_factory_test.ts @@ -0,0 +1,26 @@ +import * as chai from 'chai'; +import * as dirtyChai from 'dirty-chai'; +import * as _ from 'lodash'; +import 'mocha'; +import * as WebSocket from 'websocket'; + +import { orderbookChannelFactory } from '../src/orderbook_channel_factory'; + +chai.config.includeStack = true; +chai.use(dirtyChai); +const expect = chai.expect; + +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(); + }); + }); +}); diff --git a/packages/connect/test/node_ws_orderbook_channel_test.ts b/packages/connect/test/ws_orderbook_channel_test.ts index 5e5325e83..79100d0e2 100644 --- a/packages/connect/test/node_ws_orderbook_channel_test.ts +++ b/packages/connect/test/ws_orderbook_channel_test.ts @@ -2,16 +2,18 @@ import * as chai from 'chai'; import * as dirtyChai from 'dirty-chai'; import * as _ from 'lodash'; import 'mocha'; +import * as WebSocket from 'websocket'; -import { NodeWebSocketOrderbookChannel } from '../src/node_ws_orderbook_channel'; +import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel'; chai.config.includeStack = true; chai.use(dirtyChai); const expect = chai.expect; -describe('NodeWebSocketOrderbookChannel', () => { +describe('WebSocketOrderbookChannel', () => { const websocketUrl = 'ws://localhost:8080'; - const orderbookChannel = new NodeWebSocketOrderbookChannel(websocketUrl); + const client = new WebSocket.w3cwebsocket(websocketUrl); + const orderbookChannel = new WebSocketOrderbookChannel(client); const subscriptionOpts = { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', |