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
24 lines
791 B
TypeScript
24 lines
791 B
TypeScript
import {
|
|
listDurableObjectIds,
|
|
runDurableObjectAlarm,
|
|
runInDurableObject,
|
|
} from "cloudflare:test";
|
|
import { env } from "cloudflare:workers";
|
|
import { it } from "vitest";
|
|
|
|
it("uses other object", async ({ expect }) => {
|
|
const id = env.OTHER_OBJECT.idFromName("other-test");
|
|
const stub = env.OTHER_OBJECT.get(id);
|
|
const response = await stub.fetch("http://x");
|
|
expect(await response.text()).toBe("OtherObject body");
|
|
|
|
// Check can only use run in helpers for same-isolate classes...
|
|
await expect(runInDurableObject(stub, () => {})).rejects.toThrow();
|
|
await expect(runDurableObjectAlarm(stub)).rejects.toThrow();
|
|
|
|
// ...but can list IDs for any class
|
|
const ids = await listDurableObjectIds(env.OTHER_OBJECT);
|
|
expect(ids.length).toBe(1);
|
|
expect(ids[0].equals(id)).toBe(true);
|
|
});
|