mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
It works this way in JS. Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { describe, test, expect } from "bun:test";
|
|
|
|
test("zero args returns an otherwise empty 200 response", () => {
|
|
const response = new Response();
|
|
expect(response.status).toBe(200);
|
|
expect(response.statusText).toBe("");
|
|
});
|
|
|
|
test("undefined args don't throw", () => {
|
|
const response = new Response("", {
|
|
status: undefined,
|
|
statusText: undefined,
|
|
headers: undefined,
|
|
});
|
|
expect(response.status).toBe(200);
|
|
expect(response.statusText).toBe("");
|
|
});
|
|
|
|
test("1-arg form returns a 200 response", () => {
|
|
const response = new Response("body text");
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.statusText).toBe("");
|
|
});
|
|
|
|
describe("2-arg form", () => {
|
|
test("can fill in status/statusText, and it works", () => {
|
|
const response = new Response("body text", {
|
|
status: 202,
|
|
statusText: "Accepted.",
|
|
});
|
|
|
|
expect(response.status).toBe(202);
|
|
expect(response.statusText).toBe("Accepted.");
|
|
});
|
|
test('empty object continues to return 200/""', () => {
|
|
const response = new Response("body text", {});
|
|
|
|
expect(response.status).toBe(200);
|
|
expect(response.statusText).toBe("");
|
|
});
|
|
});
|