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 "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | |
| 5 | import * as RelayDb from "../db.ts"; |
| 6 | import * as Devices from "./Devices.ts"; |
| 7 | |
| 8 | const deviceRow = (pushToken: string | null) => ({ |
| 9 | deviceId: "device-1", |
| 10 | label: "Pixel 9", |
| 11 | platform: "android", |
| 12 | iosMajorVersion: null, |
| 13 | androidApiLevel: 36, |
| 14 | appVersion: "2.2.0", |
| 15 | pushToken, |
| 16 | preferences: { |
| 17 | notificationsEnabled: true, |
| 18 | liveActivitiesEnabled: true, |
| 19 | notifyOnApproval: true, |
| 20 | notifyOnInput: true, |
| 21 | notifyOnCompletion: true, |
| 22 | notifyOnFailure: true, |
| 23 | }, |
| 24 | updatedAt: "2026-10-28T00:00:00.000Z", |
| 25 | }); |
| 26 | |
| 27 | describe("Devices", () => { |
| 28 | it.effect.each([ |
| 29 | [null, false], |
| 30 | ["fcm-token", true], |
| 31 | ] as const)("lists notifications for push token %s as enabled: %s", ([pushToken, enabled]) => { |
| 32 | const fakeDb = { |
| 33 | select: () => ({ |
| 34 | from: () => ({ where: () => Effect.succeed([deviceRow(pushToken)]) }), |
| 35 | }), |
| 36 | } as unknown as RelayDb.RelayDb["Service"]; |
| 37 | |
| 38 | return Effect.gen(function* () { |
| 39 | const devices = yield* Devices.Devices; |
| 40 | const [device] = yield* devices.listForUser({ userId: "user-1" }); |
| 41 | |
| 42 | expect(device?.notifications.enabled).toBe(enabled); |
| 43 | }).pipe( |
| 44 | Effect.provide(Devices.layer.pipe(Layer.provide(Layer.succeed(RelayDb.RelayDb, fakeDb)))), |
| 45 | ); |
| 46 | }); |
| 47 | }); |