Skip to content

Commit

Permalink
Document whatwg-fetch Response.statusText bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Jan 27, 2021
1 parent f79b953 commit 54ac09f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/createHttpError.test.ts
Expand Up @@ -7,6 +7,9 @@ import { isWhatwgFetch } from './isWhatwgFetch';
const redirected = isWhatwgFetch ? undefined : false;
const type = isWhatwgFetch ? 'default' : undefined;

// FIXME https://github.com/github/fetch/pull/897
const emptyStatusText = isWhatwgFetch ? undefined : '';

// "new Response()" gives a 200 response:
// {
// body: null
Expand Down Expand Up @@ -244,7 +247,7 @@ test('no statusText', async () => {
expect(response.ok).toEqual(true);
expect(response.redirected).toEqual(redirected);
expect(response.status).toEqual(200);
expect(response.statusText).toEqual(isWhatwgFetch ? undefined : '');
expect(response.statusText).toEqual(emptyStatusText);
expect(response.type).toEqual(type);
expect(response.url).toEqual('');

Expand All @@ -264,7 +267,7 @@ test('no statusText', async () => {
expect(response.ok).toEqual(true);
expect(response.redirected).toEqual(redirected);
expect(response.status).toEqual(200);
expect(response.statusText).toEqual(isWhatwgFetch ? undefined : '');
expect(response.statusText).toEqual(emptyStatusText);
expect(response.type).toEqual(type);
expect(response.url).toEqual('');

Expand All @@ -288,7 +291,7 @@ if (isWhatwgFetch) {
expect(response.ok).toEqual(false);
expect(response.redirected).toEqual(redirected);
expect(response.status).toEqual(0);
expect(response.statusText).toEqual(isWhatwgFetch ? undefined : '');
expect(response.statusText).toEqual(emptyStatusText);
expect(response.type).toEqual(type);
expect(response.url).toEqual('');

Expand All @@ -308,7 +311,7 @@ if (isWhatwgFetch) {
expect(response.ok).toEqual(false);
expect(response.redirected).toEqual(redirected);
expect(response.status).toEqual(0);
expect(response.statusText).toEqual(isWhatwgFetch ? undefined : '');
expect(response.statusText).toEqual(emptyStatusText);
expect(response.type).toEqual(type);
expect(response.url).toEqual('');

Expand All @@ -327,7 +330,7 @@ if (isWhatwgFetch) {
expect(response.ok).toEqual(false);
expect(response.redirected).toEqual(redirected);
expect(response.status).toEqual(0);
expect(response.statusText).toEqual(isWhatwgFetch ? undefined : '');
expect(response.statusText).toEqual(emptyStatusText);
expect(response.type).toEqual(type);
expect(response.url).toEqual('');

Expand Down

0 comments on commit 54ac09f

Please sign in to comment.