mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
16 lines
431 B
TypeScript
16 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' })
|
|
})
|