node-serialport-bindings-cpp/test/initializers/assert-reject.js
Francis Gulotta 50f967e788
fix: bindings.close() should cause a canceled read error (#1972)
`stream` seems unaffected by this but other future interfaces may not be so forgiving.

- removed the unused disconnect handler that we passed to bindings in tests.
- moved shouldReject to a test global
- unit tested unixRead
2019-11-09 21:46:21 -05:00

9 lines
222 B
JavaScript

global.shouldReject = async (promise, errType = Error, message = 'Should have rejected') => {
try {
await promise
} catch (err) {
assert.instanceOf(err, errType)
return err
}
throw new Error(message)
}