Skip to content

Commit

Permalink
chore: use constant for TimeoutError code in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katsanva committed Nov 3, 2024
1 parent ec31144 commit 804246b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/abort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,15 @@ test('support setting the signal as a default option', async t => {
t.true(signalHandlersRemoved(), 'Abort signal event handlers not removed');
});

const timeoutErr = 23;

Check failure on line 328 in test/abort.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

The variable `timeoutErr` should be named `timeoutError`. A more descriptive name will do too.
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
test('support AbortSignal.timeout()', async t => {
const signal = AbortSignal.timeout(1);

const p = got('http://example.com', {signal});

await t.throwsAsync(p, {
code: 23,
code: timeoutErr,
message: 'The operation was aborted due to timeout',
});
});
Expand All @@ -347,7 +348,7 @@ test('support AbortSignal.timeout() without user abort', async t => {
const p = got('http://example.com', {signal});

await t.throwsAsync(p, {
code: 23,
code: timeoutErr,
message: 'The operation was aborted due to timeout',
});

Expand Down

0 comments on commit 804246b

Please sign in to comment.