Skip to content

Commit

Permalink
test: add test for empty response with json media type
Browse files Browse the repository at this point in the history
Follow-up to #648
  • Loading branch information
wolfy1339 committed Nov 29, 2023
1 parent 02b5723 commit bafecb3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,4 +1120,27 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
expect(mock.done()).toBe(true);
});
});

it("should not error for empty response body and json media type (#649)", () => {
const mock = fetchMock.sandbox().get("path:/", {
status: 200,
body: "",
headers: {
"content-length": "0",
"content-type": "application/json; charset=utf-8",
},
});

expect(request).not.toThrow();
return request("GET /", {
headers: {
accept: "application/json",
},
request: {
fetch: mock,
},
}).then((response) => {
expect(response.data).toEqual("");
});
});
});

0 comments on commit bafecb3

Please sign in to comment.