From 96a93c4b35673c951914e26d67140242c2a2de8f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 13 Jun 2017 17:39:43 +0200 Subject: Add tests for stopWatchingAsync --- test/exchange_wrapper_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index b9ac374dd..35e42e4b2 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -693,6 +693,26 @@ describe('ExchangeWrapper', () => { ); })(); }); + it('Should be able to stop watching', (done: DoneCallback) => { + (async () => { + const subscriptionOpts: SubscriptionOpts = { + fromBlock: 0, + toBlock: 'latest', + }; + const eventSubscriptionToBeStopped = await zeroEx.exchange.subscribeAsync( + ExchangeEvents.LogFill, subscriptionOpts, indexFilterValues, + ); + eventSubscriptionToBeStopped.watch((err: Error, event: ContractEvent) => { + done(new Error('Expected this subscription to have been stopped')); + }); + await eventSubscriptionToBeStopped.stopWatchingAsync(); + const fillTakerAmountInBaseUnits = new BigNumber(1); + await zeroEx.exchange.fillOrderAsync( + signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer, takerAddress, + ); + done(); + })(); + }); }); describe('#getOrderHashHexUsingContractCallAsync', () => { let makerTokenAddress: string; -- cgit v1.2.3