Skip to content

Commit 1e3a019

Browse files
committed
squash: fix test
1 parent 9715190 commit 1e3a019

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

test/fetch/request.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const {
88
Headers
99
} = require('../../')
1010
const { kState } = require('../../lib/fetch/symbols.js')
11+
const hasSignalReason = !!~process.version.localeCompare('v16.14.0', undefined, { numeric: true })
1112

1213
test('arg validation', async (t) => {
1314
// constructor
@@ -273,7 +274,9 @@ test('pre aborted signal', t => {
273274
ac.abort('gwak')
274275
const req = new Request('http://asd', { signal: ac.signal })
275276
t.equal(req.signal.aborted, true)
276-
t.equal(req.signal.reason, 'gwak')
277+
if (hasSignalReason) {
278+
t.equal(req.signal.reason, 'gwak')
279+
}
277280
t.end()
278281
})
279282

@@ -284,7 +287,11 @@ test('post aborted signal', t => {
284287
const req = new Request('http://asd', { signal: ac.signal })
285288
t.equal(req.signal.aborted, false)
286289
ac.signal.addEventListener('abort', () => {
287-
t.equals(req.signal.reason, 'gwak')
290+
if (hasSignalReason) {
291+
t.equal(req.signal.reason, 'gwak')
292+
} else {
293+
t.pass()
294+
}
288295
})
289296
ac.abort('gwak')
290297
})
@@ -294,7 +301,9 @@ test('pre aborted signal cloned', t => {
294301
ac.abort('gwak')
295302
const req = new Request('http://asd', { signal: ac.signal }).clone()
296303
t.equal(req.signal.aborted, true)
297-
t.equal(req.signal.reason, 'gwak')
304+
if (hasSignalReason) {
305+
t.equal(req.signal.reason, 'gwak')
306+
}
298307
t.end()
299308
})
300309

@@ -326,9 +335,13 @@ test('post aborted signal cloned', t => {
326335
const req = new Request('http://asd', { signal: ac.signal }).clone()
327336
t.equal(req.signal.aborted, false)
328337
ac.signal.addEventListener('abort', () => {
329-
t.pass()
338+
if (hasSignalReason) {
339+
t.equal(req.signal.reason, 'gwak')
340+
} else {
341+
t.pass()
342+
}
330343
})
331-
ac.abort()
344+
ac.abort('gwak')
332345
})
333346

334347
test('Passing headers in init', (t) => {

0 commit comments

Comments
 (0)