test(napi): make worker_threads test more complex
This commit is contained in:
parent
de27470552
commit
0dbda09cb3
2 changed files with 5 additions and 3 deletions
|
@ -3,13 +3,13 @@ import { Worker } from 'worker_threads'
|
|||
|
||||
import test from 'ava'
|
||||
|
||||
import { DEFAULT_COST } from '../index'
|
||||
import { DEFAULT_COST, Animal, Kind } from '../index'
|
||||
|
||||
test('should be able to require in worker thread', (t) => {
|
||||
const w = new Worker(join(__dirname, 'worker.js'))
|
||||
return new Promise<void>((resolve) => {
|
||||
w.on('message', (msg) => {
|
||||
t.is(msg, DEFAULT_COST)
|
||||
t.is(msg, Animal.withKind(Kind.Cat).whoami() + DEFAULT_COST)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2,4 +2,6 @@ const { parentPort } = require('worker_threads')
|
|||
|
||||
const native = require('../index')
|
||||
|
||||
parentPort.postMessage(native.DEFAULT_COST)
|
||||
parentPort.postMessage(
|
||||
native.Animal.withKind(native.Kind.Cat).whoami() + native.DEFAULT_COST,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue