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') })