From c8c86c44f8b978d74e03c11d4bb1813e76574af3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 5 Jan 2018 15:33:00 +0100 Subject: Fix callback types --- packages/0x.js/test/subscription_test.ts | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'packages/0x.js/test/subscription_test.ts') diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts index d6269f15f..f44bfecf6 100644 --- a/packages/0x.js/test/subscription_test.ts +++ b/packages/0x.js/test/subscription_test.ts @@ -11,7 +11,7 @@ import { DoneCallback } from '../src/types'; import { chaiSetup } from './utils/chai_setup'; import { constants } from './utils/constants'; -import { reportCallbackErrors } from './utils/report_callback_errors'; +import { assertNodeCallbackError } from './utils/report_callback_errors'; import { web3Factory } from './utils/web3_factory'; chaiSetup.configure(); @@ -59,13 +59,7 @@ describe('SubscriptionTest', () => { it('Should receive the Error when an error occurs while fetching the block', (done: DoneCallback) => { (async () => { const errMsg = 'Error fetching block'; - const callback = reportCallbackErrors(done)( - (err: Error, logEvent: DecodedLogEvent) => { - expect(err.message).to.be.equal(errMsg); - expect(logEvent).to.be.undefined(); - done(); - }, - ); + const callback = assertNodeCallbackError(done, errMsg); stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error(errMsg))]; zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback); await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); @@ -74,13 +68,7 @@ describe('SubscriptionTest', () => { it('Should receive the Error when an error occurs while reconciling the new block', (done: DoneCallback) => { (async () => { const errMsg = 'Error fetching logs'; - const callback = reportCallbackErrors(done)( - (err: Error, logEvent: DecodedLogEvent) => { - expect(err.message).to.be.equal(errMsg); - expect(logEvent).to.be.undefined(); - done(); - }, - ); + const callback = assertNodeCallbackError(done, errMsg); stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync').throws(new Error(errMsg))]; zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback); await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); @@ -88,7 +76,7 @@ describe('SubscriptionTest', () => { }); it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => { (async () => { - const callback = (err: Error, logEvent: DecodedLogEvent) => _.noop; + const callback = (err: Error | null, logEvent?: DecodedLogEvent) => _.noop; zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback); stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))]; zeroEx.token.unsubscribeAll(); -- cgit v1.2.3 From bef056b08407a90cb30b118935a1a155c37766bb Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 5 Jan 2018 15:58:23 +0100 Subject: Fix linter issues --- packages/0x.js/test/subscription_test.ts | 2 -- 1 file changed, 2 deletions(-) (limited to 'packages/0x.js/test/subscription_test.ts') diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts index f44bfecf6..f4c6f748f 100644 --- a/packages/0x.js/test/subscription_test.ts +++ b/packages/0x.js/test/subscription_test.ts @@ -1,6 +1,5 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { BigNumber } from '@0xproject/utils'; -import * as chai from 'chai'; import * as _ from 'lodash'; import 'mocha'; import * as Sinon from 'sinon'; @@ -15,7 +14,6 @@ import { assertNodeCallbackError } from './utils/report_callback_errors'; import { web3Factory } from './utils/web3_factory'; chaiSetup.configure(); -const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL); describe('SubscriptionTest', () => { -- cgit v1.2.3