Skip to content

Commit

Permalink
feat: add test case accept starts with 'text'
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn2468 committed Jan 17, 2024
1 parent acd0f8b commit 33699db
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,23 @@ test('.json() with invalid JSON body', async t => {
await server.close();
});

test('.json() with invalid JSON body and accept starts with text', async t => {
const server = await createHttpTestServer();
server.get('/', async (request, response) => {
t.is(request.headers.accept, 'text/plain');
response.end('not json');
});

// I think the code is a bit weird in this situation.
const responseJson = await ky.get(server.url).json();
const responseText = await ky.get(server.url).text();

t.deepEqual(responseJson, 'not json');

Check failure on line 280 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Avoid using `deepEqual` with literal primitives
t.deepEqual(responseText, 'not json');

Check failure on line 281 in test/main.ts

View workflow job for this annotation

GitHub Actions / Node.js 18

Avoid using `deepEqual` with literal primitives

await server.close();
});

test('.json() with empty body', async t => {
t.plan(2);

Expand Down

0 comments on commit 33699db

Please sign in to comment.