napi-rs/examples/napi-compat-mode/__tests__/napi4/deferred.spec.ts
forehal a781a4f27e feat(cli): brand new cli tool with both cli and programmatical usage (#1492)
BREAKING CHANGE: requires node >= 16 and some cli options have been renamed
2023-04-06 11:04:53 +08:00

15 lines
431 B
TypeScript

import test from 'ava'
const bindings = require('../../index.node')
test('should resolve deferred from background thread', async (t) => {
const promise = bindings.testDeferred(false)
t.assert(promise instanceof Promise)
const result = await promise
t.is(result, 15)
})
test('should reject deferred from background thread', async (t) => {
await t.throwsAsync(() => bindings.testDeferred(true), { message: 'Fail' })
})