Files
t3tui/test/config.test.ts
T
Callum Alpass 626d37a4e9 New threads, model and mode picker, alerts, $EDITOR and terminal attach
- c starts a draft thread (project, model, mode, worktree) launched with orchestration.launchThread
- m picks model, provider options and access mode from the server's providers, following the web's provider lock; model changes ride on the next message
- Alerts port T3's notification gate: bell, OSC 9/99 desktop notifications when unfocused, in-app flash
- ctrl+g edits the message in $EDITOR; ctrl+j attaches to the thread's T3 terminal
- Credential gains terminal:read
2026-11-02 18:55:47 +11:00

35 lines
1.5 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { cycleConfig, DEFAULT_CONFIG, formatClock, parseConfig } from "../src/config.ts";
import { settingRows } from "../src/model/settings.ts";
describe("config", () => {
test("keeps valid values and defaults the rest", () => {
expect(parseConfig({ followUpBehavior: "queue", sendShortcut: "nope", diffIgnoreWhitespace: false, extra: 1 })).toEqual({
...DEFAULT_CONFIG,
followUpBehavior: "queue",
diffIgnoreWhitespace: false,
});
expect(parseConfig(null)).toEqual(DEFAULT_CONFIG);
});
test("cycles through each setting's choices", () => {
const once = cycleConfig(DEFAULT_CONFIG, "timestampFormat");
expect(once.timestampFormat).toBe("12-hour");
expect(cycleConfig(cycleConfig(once, "timestampFormat"), "timestampFormat").timestampFormat).toBe("locale");
expect(cycleConfig(DEFAULT_CONFIG, "diffIgnoreWhitespace").diffIgnoreWhitespace).toBe(false);
});
test("formats clock times", () => {
expect(formatClock("09:05", "24-hour")).toBe("09:05");
expect(formatClock("21:30", "12-hour")).toMatch(/^9:30\s?PM$/i);
expect(formatClock("bad", "24-hour")).toBe("bad");
});
test("labels settings for the settings view", () => {
const rows = settingRows({ ...DEFAULT_CONFIG, followUpBehavior: "queue" });
expect(rows.map((row) => row.key)).toEqual(["followUpBehavior", "sendShortcut", "timestampFormat", "diffIgnoreWhitespace", "notificationMode", "inAppNotificationsEnabled"]);
expect(rows[0]?.value).toBe("queues");
});
});