2020-08-24 17:16:35 +09:00
|
|
|
import test from 'ava'
|
|
|
|
|
|
|
|
import { napiVersion } from '../napi-version'
|
2020-07-03 01:31:50 +09:00
|
|
|
|
|
|
|
const bindings = require('../../index.node')
|
2020-06-19 21:42:18 +09:00
|
|
|
|
|
|
|
test('should call callback with the first arguments as an Error', async (t) => {
|
2020-07-03 01:31:50 +09:00
|
|
|
if (napiVersion < 4) {
|
|
|
|
t.is(bindings.testTsfnError, undefined)
|
|
|
|
return
|
|
|
|
}
|
2020-08-24 19:01:55 +09:00
|
|
|
await new Promise((resolve, reject) => {
|
2020-08-24 17:16:35 +09:00
|
|
|
bindings.testTsfnError((err: Error) => {
|
2020-06-19 21:42:18 +09:00
|
|
|
try {
|
|
|
|
t.is(err instanceof Error, true)
|
|
|
|
t.is(err.message, 'invalid')
|
|
|
|
resolve()
|
|
|
|
} catch (err) {
|
|
|
|
reject(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|