From 31f6934787f5f6d06abba4f488ce49f6d0cdbbee Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 9 Nov 2017 15:18:08 -0500 Subject: Add a test that a second subscription fails --- test/order_state_watcher_test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/order_state_watcher_test.ts b/test/order_state_watcher_test.ts index 5569d2354..913ccf602 100644 --- a/test/order_state_watcher_test.ts +++ b/test/order_state_watcher_test.ts @@ -84,6 +84,20 @@ describe('OrderStateWatcher', () => { zeroEx.orderStateWatcher.removeOrder(nonExistentOrderHash); }); }); + describe('#subscribe', async () => { + afterEach(async () => { + zeroEx.orderStateWatcher.unsubscribe(); + }); + it('should fail when trying to subscribe twice', (done: DoneCallback) => { + zeroEx.orderStateWatcher.subscribe(_.noop); + try { + zeroEx.orderStateWatcher.subscribe(_.noop); + done(new Error('Expected the second subscription to fail')); + } catch (err) { + done(); + } + }); + }); describe('tests with cleanup', async () => { afterEach(async () => { zeroEx.orderStateWatcher.unsubscribe(); -- cgit v1.2.3