◐ Shell
clean mode source ↗

test: simplify test-tls-connect-abort-controller.js · nodejs/node@99b2369

Original file line numberDiff line numberDiff line change

@@ -23,14 +23,11 @@ server.listen(0, common.mustCall(async () => {

2323

rejectUnauthorized: false,

2424

});

2525
26-

const assertAbort = async (socket, testName) => {

27-

try {

28-

await once(socket, 'close');

29-

assert.fail(`close ${testName} should have thrown`);

30-

} catch (err) {

31-

assert.strictEqual(err.name, 'AbortError');

32-

}

33-

};

26+

function assertAbort(socket, testName) {

27+

return assert.rejects(() => once(socket, 'close'), {

28+

name: 'AbortError',

29+

}, `close ${testName} should have thrown`);

30+

}

3431
3532

async function postAbort() {

3633

const ac = new AbortController();