The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
| 1 | import { expect } from "bun:test"; |
| 2 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 3 | import * as Neon from "@alchemy.run/neon"; |
| 4 | import * as Test from "@alchemy.run/test/Bun"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import * as Layer from "effect/Layer"; |
| 7 | import Stack from "./alchemy.run.ts"; |
| 8 | import { connect, history } from "./client.ts"; |
| 9 | |
| 10 | // #region show |
| 11 | // #region make |
| 12 | const { test, beforeAll, afterAll, deploy, destroy } = Test.make({ |
| 13 | providers: Layer.mergeAll(Cloudflare.providers(), Neon.providers()), |
| 14 | // #region dev |
| 15 | dev: !!process.env.LOCAL, |
| 16 | // #endregion dev |
| 17 | // #region stage |
| 18 | stage: process.env.STAGE, |
| 19 | // #endregion stage |
| 20 | }); |
| 21 | // #endregion make |
| 22 | // #region deploy |
| 23 | |
| 24 | const stack = beforeAll(deploy(Stack)); |
| 25 | afterAll(destroy(Stack)); |
| 26 | // #endregion deploy |
| 27 | // #region test |
| 28 | |
| 29 | test( |
| 30 | "a message reaches everyone in the room", |
| 31 | Effect.gen(function* () { |
| 32 | const { url } = yield* stack; |
| 33 | const alice = yield* connect(`${url}/rooms/lobby`); |
| 34 | const bob = yield* connect(`${url}/rooms/lobby`); |
| 35 | |
| 36 | yield* alice.send("hi bob"); |
| 37 | expect(yield* bob.receive).toBe("hi bob"); |
| 38 | // #region history |
| 39 | expect(yield* history(url, "lobby")).toContain("hi bob"); |
| 40 | // #endregion history |
| 41 | }), |
| 42 | ); |
| 43 | // #endregion test |
| 44 | // #endregion show |