Avoid the release of Zalgo (#1295)

This commit is contained in:
Tomas Della Vedova
2020-09-10 15:27:27 +02:00
committed by delvedor
parent 457c30eb89
commit 59203811dd
4 changed files with 105 additions and 19 deletions

View File

@ -299,6 +299,22 @@ test('ConfigurationError (promises)', t => {
})
})
test('The callback with a sync error should be called in the next tick', t => {
t.plan(4)
const client = new Client({
node: 'http://localhost:9200'
})
const transportReturn = client.index({ body: { foo: 'bar' } }, (err, result) => {
t.ok(err instanceof errors.ConfigurationError)
})
t.type(transportReturn.then, 'function')
t.type(transportReturn.catch, 'function')
t.type(transportReturn.abort, 'function')
})
if (Number(process.version.split('.')[0].slice(1)) >= 8) {
require('./api-async')(test)
}