Skip to content

Commit a84a506

Browse files
test-fixup, use assert
Signed-off-by: marcopiraccini <[email protected]>
1 parent 398e700 commit a84a506

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

test/parallel/test-whatwg-transformstream-cancel-write-race.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const common = require('../common');
4+
const assert = require('assert');
45
const { TransformStream } = require('stream/web');
56
const { setTimeout } = require('timers/promises');
67

@@ -29,26 +30,24 @@ async function test() {
2930
// Late write racing with cancel.
3031
const pendingLateWrite = writer.write('late-write');
3132

32-
const results = await Promise.allSettled([
33+
const [
34+
readResult,
35+
cancelResult,
36+
lateWriteResult,
37+
] = await Promise.allSettled([
3338
pendingRead,
3439
pendingCancel,
3540
pendingLateWrite,
3641
]);
3742

38-
// pendingRead should fulfill (with done:true or a value).
39-
// pendingCancel should fulfill.
40-
// pendingLateWrite may reject, but must NOT reject with an internal
41-
// TypeError about transformAlgorithm not being a function.
42-
for (const result of results) {
43-
if (result.status === 'rejected') {
44-
const err = result.reason;
45-
if (err instanceof TypeError &&
46-
/transformAlgorithm is not a function/.test(err.message)) {
47-
throw new Error(
48-
'Internal implementation error leaked: ' + err.message
49-
);
50-
}
51-
}
43+
assert.strictEqual(readResult.status, 'fulfilled');
44+
assert.strictEqual(cancelResult.status, 'fulfilled');
45+
if (lateWriteResult.status === 'rejected') {
46+
const err = lateWriteResult.reason;
47+
const isNotAFunction = err instanceof TypeError &&
48+
/transformAlgorithm is not a function/.test(err.message);
49+
assert.ok(!isNotAFunction,
50+
`Internal implementation error leaked: ${err.message}`);
5251
}
5352
}
5453

0 commit comments

Comments
 (0)