Skip to content

Commit

Permalink
add unit test for http status info
Browse files Browse the repository at this point in the history
  • Loading branch information
lenkan committed Jan 25, 2024
1 parent 78d8fb0 commit dfd37b0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/app/clienting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,29 @@ describe('SignifyClient', () => {
'ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK'
);
});

test('includes HTTP status info in error message', async () => {
await libsodium.ready;
const bran = '0123456789abcdefghijk';
const client = new SignifyClient(url, bran, Tier.low, boot_url);

await client.connect();

fetchMock.mockResolvedValue(
new Response('Error info', {
status: 400,
statusText: 'Bad Request',
})
);

const error = await client
.fetch('/somepath', 'GET', undefined)
.catch((e) => e);

assert(error instanceof Error);
assert.equal(
error.message,
'HTTP GET /somepath - 400 Bad Request - Error info'
);
});
});

0 comments on commit dfd37b0

Please sign in to comment.