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 { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { reconcileSnoozeDraft, sortSnoozeRows } from "./SnoozePresetsSettings.logic"; |
| 4 | |
| 5 | describe("reconcileSnoozeDraft", () => { |
| 6 | it("keeps the draft while our own writes echo back in order", () => { |
| 7 | expect(reconcileSnoozeDraft(["a", "b"], "a")).toEqual({ adopt: false, pending: ["b"] }); |
| 8 | expect(reconcileSnoozeDraft(["b"], "b")).toEqual({ adopt: false, pending: [] }); |
| 9 | }); |
| 10 | |
| 11 | it("adopts a value from elsewhere, even one this editor wrote earlier", () => { |
| 12 | expect(reconcileSnoozeDraft(["b"], "c")).toEqual({ adopt: true }); |
| 13 | // "a" was written and acknowledged before; seeing it again means someone restored it. |
| 14 | expect(reconcileSnoozeDraft([], "a")).toEqual({ adopt: true }); |
| 15 | }); |
| 16 | |
| 17 | it("acknowledges every earlier write when a later one echoes", () => { |
| 18 | expect(reconcileSnoozeDraft(["a", "b", "a"], "b")).toEqual({ adopt: false, pending: ["a"] }); |
| 19 | }); |
| 20 | }); |
| 21 | |
| 22 | describe("sortSnoozeRows", () => { |
| 23 | it("orders rows by wake time and puts a passed today option last", () => { |
| 24 | // 16:00 local, so 20 hours wakes tomorrow and today 09:00 has passed. |
| 25 | const now = new Date(2026, 9, 28, 16, 0); |
| 26 | const sorted = sortSnoozeRows( |
| 27 | [ |
| 28 | { kind: "after", minutes: 20 * 60 }, |
| 29 | { kind: "at", day: "today", time: "09:00" }, |
| 30 | { kind: "at", day: "today", time: "18:00" }, |
| 31 | { kind: "after", minutes: 60 }, |
| 32 | ], |
| 33 | ["20h", "passed", "evening", "1h"], |
| 34 | now, |
| 35 | ); |
| 36 | expect(sorted.keys).toEqual(["1h", "evening", "20h", "passed"]); |
| 37 | }); |
| 38 | }); |