diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 04:15:01 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 05:15:47 +0800 |
commit | 8c54e9a8731ccd831daf5533070302746af575e5 (patch) | |
tree | 1b9b43da9e64f5499078983f485f3f7548082e63 /packages/0x.js | |
parent | 062f85e5069d0c2d56cd10bdb8a31a6d0a6c88dc (diff) | |
download | dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.tar dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.tar.gz dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.tar.bz2 dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.tar.lz dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.tar.xz dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.tar.zst dexon-sol-tools-8c54e9a8731ccd831daf5533070302746af575e5.zip |
Add a regression test
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/test/subscription_test.ts | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts index df40ae75a..7a818af37 100644 --- a/packages/0x.js/test/subscription_test.ts +++ b/packages/0x.js/test/subscription_test.ts @@ -68,22 +68,40 @@ describe('SubscriptionTest', () => { _.each(stubs, s => s.restore()); stubs = []; }); - it('Should receive the Error when an error occurs', (done: DoneCallback) => { + it('Should receive the Error when an error occurs while fetching the block', (done: DoneCallback) => { (async () => { + const errMsg = 'Error fetching block'; const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => { - expect(err).to.not.be.null(); + expect(err).to.be.equal(errMsg); expect(logEvent).to.be.undefined(); done(); }; stubs = [ Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync') - .throws('JSON RPC error'), + .throws(errMsg), ]; zeroEx.token.subscribe( tokenAddress, TokenEvents.Approval, indexFilterValues, callback); await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); })().catch(done); - }); + }); + it('Should receive the Error when an error occurs while reconciling the new block', (done: DoneCallback) => { + (async () => { + const errMsg = 'Error fetching logs'; + const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => { + expect(err).to.be.equal(errMsg); + expect(logEvent).to.be.undefined(); + done(); + }; + stubs = [ + Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync') + .throws(errMsg), + ]; + zeroEx.token.subscribe( + tokenAddress, TokenEvents.Approval, indexFilterValues, callback); + await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); + })().catch(done); + }); it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => { (async () => { const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop; @@ -96,6 +114,6 @@ describe('SubscriptionTest', () => { zeroEx.token.unsubscribeAll(); done(); })().catch(done); - }); + }); }); }); |