From bc341746bb9f99931c05c1a363c3a6bd5bf090bf Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:20:00 +0000 Subject: [PATCH] cleanup --- test/fetch/request.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/test/fetch/request.js b/test/fetch/request.js index 8ee4c8ed06d..1f4061b2ebe 100644 --- a/test/fetch/request.js +++ b/test/fetch/request.js @@ -11,8 +11,6 @@ const { fetch } = require('../../') -const hasSignalReason = 'reason' in AbortSignal.prototype - test('arg validation', async (t) => { // constructor assert.throws(() => { @@ -261,23 +259,17 @@ test('pre aborted signal', () => { ac.abort('gwak') const req = new Request('http://asd', { signal: ac.signal }) assert.strictEqual(req.signal.aborted, true) - if (hasSignalReason) { - assert.strictEqual(req.signal.reason, 'gwak') - } + assert.strictEqual(req.signal.reason, 'gwak') }) test('post aborted signal', (t) => { - const { strictEqual, ok } = tspl(t, { plan: 2 }) + const { strictEqual } = tspl(t, { plan: 2 }) const ac = new AbortController() const req = new Request('http://asd', { signal: ac.signal }) strictEqual(req.signal.aborted, false) ac.signal.addEventListener('abort', () => { - if (hasSignalReason) { - strictEqual(req.signal.reason, 'gwak') - } else { - ok(true) - } + strictEqual(req.signal.reason, 'gwak') }, { once: true }) ac.abort('gwak') }) @@ -287,9 +279,7 @@ test('pre aborted signal cloned', () => { ac.abort('gwak') const req = new Request('http://asd', { signal: ac.signal }).clone() assert.strictEqual(req.signal.aborted, true) - if (hasSignalReason) { - assert.strictEqual(req.signal.reason, 'gwak') - } + assert.strictEqual(req.signal.reason, 'gwak') }) test('URLSearchParams body with Headers object - issue #1407', async () => { @@ -314,17 +304,13 @@ test('URLSearchParams body with Headers object - issue #1407', async () => { }) test('post aborted signal cloned', (t) => { - const { strictEqual, ok } = tspl(t, { plan: 2 }) + const { strictEqual } = tspl(t, { plan: 2 }) const ac = new AbortController() const req = new Request('http://asd', { signal: ac.signal }).clone() strictEqual(req.signal.aborted, false) ac.signal.addEventListener('abort', () => { - if (hasSignalReason) { - strictEqual(req.signal.reason, 'gwak') - } else { - ok(true) - } + strictEqual(req.signal.reason, 'gwak') }, { once: true }) ac.abort('gwak') })