From 0dbda09cb3761f47dac736ffd4df417a5ea22bf0 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 22 Dec 2021 00:12:21 +0800 Subject: [PATCH] test(napi): make worker_threads test more complex --- examples/napi/__test__/worker-thread.spec.ts | 4 ++-- examples/napi/__test__/worker.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/napi/__test__/worker-thread.spec.ts b/examples/napi/__test__/worker-thread.spec.ts index 1f2251f3..337fb5e8 100644 --- a/examples/napi/__test__/worker-thread.spec.ts +++ b/examples/napi/__test__/worker-thread.spec.ts @@ -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((resolve) => { w.on('message', (msg) => { - t.is(msg, DEFAULT_COST) + t.is(msg, Animal.withKind(Kind.Cat).whoami() + DEFAULT_COST) resolve() }) }) diff --git a/examples/napi/__test__/worker.js b/examples/napi/__test__/worker.js index 84239acc..fee47128 100644 --- a/examples/napi/__test__/worker.js +++ b/examples/napi/__test__/worker.js @@ -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, +)