mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
Some checks failed
deploy / deploy (push) Waiting to run
generate / generate (push) Waiting to run
nix-eval / nix-eval (push) Waiting to run
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
publish / publish (push) Blocked by required conditions
publish / version (push) Waiting to run
publish / build-cli (push) Blocked by required conditions
publish / sign-cli-macos (push) Blocked by required conditions
publish / sign-cli-windows (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
test / unit (linux) (push) Waiting to run
test / unit (windows) (push) Waiting to run
test / e2e (linux) (push) Waiting to run
test / e2e (windows) (push) Waiting to run
typecheck / typecheck (push) Waiting to run
storybook / storybook build (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Has been cancelled
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Has been cancelled
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Has been cancelled
nix-hashes / update-hashes (push) Has been cancelled
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { isoDay } from "../src/lib/format"
|
|
import { jsonUrl, markdownUrl, prefersMarkdown } from "../src/lib/language"
|
|
|
|
describe("markdown negotiation", () => {
|
|
test("agents that list markdown first get markdown", () => {
|
|
expect(prefersMarkdown("text/markdown, text/html, */*")).toBe(true)
|
|
expect(prefersMarkdown("text/x-markdown, */*")).toBe(true)
|
|
expect(prefersMarkdown("text/markdown;q=0.9, text/html;q=0.8")).toBe(true)
|
|
})
|
|
|
|
test("browsers and html-first clients get html", () => {
|
|
expect(prefersMarkdown("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")).toBe(false)
|
|
expect(prefersMarkdown("text/html, text/markdown;q=0.5")).toBe(false)
|
|
expect(prefersMarkdown("*/*")).toBe(false)
|
|
expect(prefersMarkdown(null)).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe("agent format urls", () => {
|
|
test("the home page maps to index files", () => {
|
|
expect(markdownUrl("/data/")).toBe("https://opencode.ai/data/index.md")
|
|
expect(jsonUrl("/data")).toBe("https://opencode.ai/data/index.json")
|
|
})
|
|
|
|
test("other pages append the extension", () => {
|
|
expect(markdownUrl("/data/deepseek")).toBe("https://opencode.ai/data/deepseek.md")
|
|
expect(jsonUrl("/data/deepseek/deepseek-v4-1-flash")).toBe(
|
|
"https://opencode.ai/data/deepseek/deepseek-v4-1-flash.json",
|
|
)
|
|
})
|
|
})
|
|
|
|
describe("iso days", () => {
|
|
test("series labels resolve against the update time", () => {
|
|
expect(isoDay("Aug 7", "2026-10-01T22:16:22.000Z")).toBe("2026-08-07")
|
|
expect(isoDay("Oct 1", "2026-10-01T22:16:22.000Z")).toBe("2026-10-01")
|
|
})
|
|
|
|
test("labels from December stay in the previous year after New Year", () => {
|
|
expect(isoDay("Dec 30", "2027-01-02T08:00:00.000Z")).toBe("2026-12-30")
|
|
expect(isoDay("Jan 2", "2027-01-02T08:00:00.000Z")).toBe("2027-01-02")
|
|
})
|
|
|
|
test("unrecognized labels pass through", () => {
|
|
expect(isoDay("Week 32", "2026-10-01T22:16:22.000Z")).toBe("Week 32")
|
|
})
|
|
})
|