MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / test

Function test

test/async_worker_persistent.js:5–19  ·  view source on GitHub ↗
(binding, succeed)

Source from the content-addressed store, hash-verified

3const assert = require('assert');
4
5function test (binding, succeed) {
6 return new Promise((resolve) =>
7 // Can't pass an arrow function to doWork because that results in an
8 // undefined context inside its body when the function gets called.
9 binding.doWork(succeed, function (e) {
10 setImmediate(() => {
11 // If the work is supposed to fail, make sure there's an error.
12 assert.strictEqual(succeed || e.message === 'test error', true);
13 assert.strictEqual(binding.workerGone, false);
14 binding.deleteWorker();
15 assert.strictEqual(binding.workerGone, true);
16 resolve();
17 });
18 }));
19}
20
21module.exports = require('./common').runTest(async binding => {
22 await test(binding.persistentasyncworker, false);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected