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
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { describe, it } from "vitest";
|
|
import { getPlatformProxy } from "./shared";
|
|
|
|
describe("getPlatformProxy - cf", () => {
|
|
it("should provide mock data", async ({ expect }) => {
|
|
const { cf, dispose } = await getPlatformProxy();
|
|
try {
|
|
expect(cf).toMatchObject({
|
|
colo: "DFW",
|
|
city: "Austin",
|
|
regionCode: "TX",
|
|
});
|
|
} finally {
|
|
await dispose();
|
|
}
|
|
});
|
|
|
|
it("should match the production runtime cf object", async ({ expect }) => {
|
|
const { cf, dispose } = await getPlatformProxy();
|
|
try {
|
|
expect(cf.constructor.name).toBe("Object");
|
|
|
|
expect(() => {
|
|
cf.city = "test city";
|
|
}).toThrow(
|
|
"Cannot assign to read only property 'city' of object '#<Object>'"
|
|
);
|
|
expect(cf.city).not.toBe("test city");
|
|
|
|
expect(() => {
|
|
cf.newField = "test new field";
|
|
}).toThrow("Cannot add property newField, object is not extensible");
|
|
expect("newField" in cf).toBe(false);
|
|
|
|
expect(cf.botManagement).toMatchObject({
|
|
score: 99,
|
|
});
|
|
expect(Object.isFrozen(cf.botManagement)).toBe(true);
|
|
} finally {
|
|
await dispose();
|
|
}
|
|
});
|
|
});
|