diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-10 20:51:09 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-11 20:22:04 +0800 |
commit | 292c3bbff81f6e1364109981123a35b1cb32f693 (patch) | |
tree | b609eb040272a049d0b2980bb9b103288d6f512b /packages/0x.js/test/utils | |
parent | 065570ebf57eb37b14ffd0b2fe131c3dcec4064a (diff) | |
download | dexon-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/utils')
-rw-r--r-- | packages/0x.js/test/utils/report_callback_errors.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/0x.js/test/utils/report_callback_errors.ts b/packages/0x.js/test/utils/report_callback_errors.ts index a7d9e61be..27c9745c9 100644 --- a/packages/0x.js/test/utils/report_callback_errors.ts +++ b/packages/0x.js/test/utils/report_callback_errors.ts @@ -25,7 +25,7 @@ export const reportNoErrorCallbackErrors = (done: DoneCallback, expectToBeCalled }; }; -export const reportNodeCallbackErrors = (done: DoneCallback) => { +export const reportNodeCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => { return <T>(f?: (value: T) => void) => { const wrapped = (error: Error | null, value: T | undefined) => { if (!_.isNull(error)) { @@ -37,7 +37,9 @@ export const reportNodeCallbackErrors = (done: DoneCallback) => { } try { f(value as T); - done(); + if (expectToBeCalledOnce) { + done(); + } } catch (err) { done(err); } |