aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/event_watcher_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-01-10 20:51:09 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-01-11 20:22:04 +0800
commit292c3bbff81f6e1364109981123a35b1cb32f693 (patch)
treeb609eb040272a049d0b2980bb9b103288d6f512b /packages/0x.js/test/event_watcher_test.ts
parent065570ebf57eb37b14ffd0b2fe131c3dcec4064a (diff)
downloaddexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.tar
dexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.tar.gz
dexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.tar.bz2
dexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.tar.lz
dexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.tar.xz
dexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.tar.zst
dexon-sol-tools-292c3bbff81f6e1364109981123a35b1cb32f693.zip
Make some callbacks failable and add error handling
Diffstat (limited to 'packages/0x.js/test/event_watcher_test.ts')
-rw-r--r--packages/0x.js/test/event_watcher_test.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/0x.js/test/event_watcher_test.ts b/packages/0x.js/test/event_watcher_test.ts
index ace1cd5d9..f92fb2b02 100644
--- a/packages/0x.js/test/event_watcher_test.ts
+++ b/packages/0x.js/test/event_watcher_test.ts
@@ -10,6 +10,7 @@ import { EventWatcher } from '../src/order_watcher/event_watcher';
import { DoneCallback } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
+import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
@@ -77,13 +78,14 @@ describe('EventWatcher', () => {
const getLogsStub = Sinon.stub(web3Wrapper, 'getLogsAsync');
getLogsStub.onCall(0).returns(logs);
stubs.push(getLogsStub);
- const callback = (event: LogEvent) => {
+ const expectedToBeCalledOnce = false;
+ const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
const expectedLogEvent = expectedLogEvents.shift();
expect(event).to.be.deep.equal(expectedLogEvent);
if (_.isEmpty(expectedLogEvents)) {
done();
}
- };
+ });
eventWatcher.subscribe(callback);
});
it('correctly computes the difference and emits only changes', (done: DoneCallback) => {
@@ -111,13 +113,14 @@ describe('EventWatcher', () => {
getLogsStub.onCall(0).returns(initialLogs);
getLogsStub.onCall(1).returns(changedLogs);
stubs.push(getLogsStub);
- const callback = (event: LogEvent) => {
+ const expectedToBeCalledOnce = false;
+ const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
const expectedLogEvent = expectedLogEvents.shift();
expect(event).to.be.deep.equal(expectedLogEvent);
if (_.isEmpty(expectedLogEvents)) {
done();
}
- };
+ });
eventWatcher.subscribe(callback);
});
});