opencode/packages/theme/test/theme.test.ts

21 lines
898 B
TypeScript

import { expect, test } from "bun:test"
import { migrateV1, resolveThemeDocument } from "../src/tui/index.js"
import type { ThemeV1Json } from "../src/tui/v1.js"
const source: ThemeV1Json = await Bun.file(
new URL("../../tui/src/theme/assets/opencode.json", import.meta.url),
).json()
const document = migrateV1(source)
test.each(["light", "dark"] as const)("resolves %s themes without status tokens", (mode) => {
const theme = resolveThemeDocument(document, mode)
expect("status" in theme.text).toBeFalse()
expect(theme.hue.accent[800]).toBeDefined()
expect(theme.hue.interactive[800]).toBeDefined()
expect(theme.thinkingOpacity).toBe(0.6)
})
test("migrates custom V1 thinkingOpacity into resolved V2 themes", () => {
const custom = resolveThemeDocument(migrateV1({ ...source, theme: { ...source.theme, thinkingOpacity: 1 } }), "dark")
expect(custom.thinkingOpacity).toBe(1)
})