70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
23 lines
684 B
TypeScript
23 lines
684 B
TypeScript
import { Request } from "miniflare";
|
|
import { test } from "vitest";
|
|
|
|
test("Request: clone: returns correctly typed value", async ({ expect }) => {
|
|
const request = new Request("http://localhost/", {
|
|
method: "POST",
|
|
body: "text",
|
|
cf: { cacheKey: "key" },
|
|
});
|
|
|
|
const clone1 = request.clone();
|
|
const clone2 = clone1.clone(); // Test cloning a clone
|
|
|
|
expect(clone1).toBeInstanceOf(Request);
|
|
expect(clone2).toBeInstanceOf(Request);
|
|
expect(request.method).toBe("POST");
|
|
expect(clone1.method).toBe("POST");
|
|
expect(clone2.method).toBe("POST");
|
|
expect(await request.text()).toBe("text");
|
|
expect(await clone1.text()).toBe("text");
|
|
expect(await clone2.text()).toBe("text");
|
|
});
|