Skip to content

Commit

Permalink
fix: check if server receives request after abort
Browse files Browse the repository at this point in the history
  • Loading branch information
kadhirr committed Dec 17, 2024
1 parent b05f3ad commit 4af46fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ test('throws DOMException/Error with name AbortError when aborted by user', asyn

test('throws AbortError when signal was aborted before request', async t => {
const server = await createHttpTestServer();
// eslint-disable-next-line @typescript-eslint/no-empty-function
server.get('/', () => {});
let requestCount = 0;
server.get('/', () => {requestCount += 1;});

Check failure on line 719 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Statement inside of curly braces should be on next line.

Check failure on line 719 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

This line has 2 statements. Maximum allowed is 1.

Check failure on line 719 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.

const abortController = new AbortController();
const {signal} = abortController;
Expand All @@ -728,6 +728,7 @@ test('throws AbortError when signal was aborted before request', async t => {

t.true(['DOMException', 'Error'].includes(error.constructor.name), `Expected DOMException or Error, got ${error.constructor.name}`);
t.is(error.name, 'AbortError', `Expected AbortError, got ${error.name}`);
t.is(requestCount,0,"Request count is more than 0, server received request.");

Check failure on line 731 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

A space is required after ','.

Check failure on line 731 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

A space is required after ','.

Check failure on line 731 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Strings must use singlequote.
});

test('throws AbortError when aborted via Request', async t => {
Expand Down

0 comments on commit 4af46fe

Please sign in to comment.