test: improve test-worker-message-port-message-before-close

Replace a wrong comment with a correct assertion and await all async
operations inside the async function.

PR-URL: https://github.com/nodejs/node/pull/29483
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Anna Henningsen 2019-09-07 21:48:43 +02:00
parent b34f05ecf2
commit d7c5ffc7a4
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -28,11 +28,11 @@ async function test() {
for (let i = 0; i < 10000; i++) { for (let i = 0; i < 10000; i++) {
const { port1, port2 } = new MessageChannel(); const { port1, port2 } = new MessageChannel();
worker.postMessage({ port: port2 }, [ port2 ]); worker.postMessage({ port: port2 }, [ port2 ]);
await once(port1, 'message'); // 'complexObject' assert.deepStrictEqual(await once(port1, 'message'), ['firstMessage']);
assert.deepStrictEqual(await once(port1, 'message'), ['lastMessage']); assert.deepStrictEqual(await once(port1, 'message'), ['lastMessage']);
} }
worker.terminate(); await worker.terminate();
} }
test().then(common.mustCall()); test().then(common.mustCall());