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, 04:45 UTC
| 1 | import { expect, test } from "@effect/vitest"; |
| 2 | import * as Story from "foldkit/story"; |
| 3 | import { UserId } from "../src/User.id.ts"; |
| 4 | import { Message, type Model, SignIn, update, WriteNote } from "../src/web/Notes.ts"; |
| 5 | |
| 6 | const signedOut: Model = { user: null, draft: "", notes: [], error: null }; |
| 7 | const sam: Model = { |
| 8 | user: { userId: UserId.make("u-sam"), name: "Sam" }, |
| 9 | draft: "", |
| 10 | notes: [], |
| 11 | error: null, |
| 12 | }; |
| 13 | |
| 14 | test("signing in sends the browser to the chosen provider", () => |
| 15 | Story.story( |
| 16 | update, |
| 17 | Story.given(signedOut), |
| 18 | Story.message(Message.ClickedSignIn({ provider: "github" })), |
| 19 | Story.Command.resolve(SignIn, Message.Failed({ reason: "Redirecting" })), |
| 20 | Story.model((next) => expect(next.user).toBeNull()), |
| 21 | )); |
| 22 | |
| 23 | test("a note is written to the user's notebook, and arrives from the watch", () => |
| 24 | Story.story( |
| 25 | update, |
| 26 | Story.given(sam), |
| 27 | Story.message(Message.ChangedDraft({ text: "buy milk" })), |
| 28 | Story.message(Message.SubmittedNote()), |
| 29 | Story.Command.resolve(WriteNote, Message.Saved()), |
| 30 | Story.model((next) => { |
| 31 | expect(next.draft).toBe(""); |
| 32 | expect(next.notes).toEqual([]); |
| 33 | }), |
| 34 | Story.message(Message.GotNotes({ notes: ["buy milk"] })), |
| 35 | Story.model((next) => expect(next.notes).toEqual(["buy milk"])), |
| 36 | )); |