mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 12:10:45 +03:00
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import path from "node:path"
|
|
|
|
const root = path.resolve(import.meta.dir, "..")
|
|
// The licensed mono face the site used before OpenTUI Mono, and its foundry. Built from parts so
|
|
// this file doesn't match itself; the lookahead skips codes like "TX020" in vendored bundles.
|
|
const retired = new RegExp(["t", "x-?02(?!\\d)", "|", "be", "rkeley"].join(""), "i")
|
|
|
|
describe("fonts", () => {
|
|
test("no file names or mentions the retired mono face", async () => {
|
|
const files = (await Bun.$`git ls-files -co --exclude-standard`.cwd(root).text()).split("\n").filter(Boolean)
|
|
const hits = (
|
|
await Promise.all(
|
|
files.map(async (file) => {
|
|
if (retired.test(file)) return [file]
|
|
const data = Bun.file(path.join(root, file))
|
|
if (!(await data.exists())) return []
|
|
const bytes = new Uint8Array(await data.arrayBuffer())
|
|
// Text files only, as grep -I reads them.
|
|
if (bytes.subarray(0, 8000).includes(0)) return []
|
|
return new TextDecoder()
|
|
.decode(bytes)
|
|
.split("\n")
|
|
.flatMap((line, index) => (retired.test(line) ? [`${file}:${index + 1}`] : []))
|
|
}),
|
|
)
|
|
).flat()
|
|
expect(hits).toEqual([])
|
|
})
|
|
|
|
test("the mono stack starts with OpenTUI Mono, served from our own files", async () => {
|
|
const css = await Bun.file(path.join(root, "src/component/site/site.css")).text()
|
|
expect(css).toMatch(/--font-mono:\s*var\(--mono-choice,\) "OpenTUI Mono",/)
|
|
const ranges = await Bun.file(path.join(root, "src/asset/fonts/opentui-mono.json")).json()
|
|
expect(Object.keys(ranges)).toEqual(["latin", "rest"])
|
|
expect(await Bun.file(path.join(root, "src/asset/fonts/OpenTUIMono-OFL.txt")).exists()).toBe(true)
|
|
})
|
|
})
|