opencode/packages/core/test/opencode-api-skill.test.ts
opencodejr[bot] 66d53a82d0
fix(core): make the API skill and cd worktree tests pass on Windows (#66115)
Co-authored-by: opencodejr[bot] <348916617+opencodejr[bot]@users.noreply.github.com>
2026-11-24 10:19:10 -05:00

16 lines
833 B
TypeScript

import { expect, test } from "bun:test"
import path from "node:path"
import { directory, render } from "../script/generate-api-skill"
test("the opencode skill's API reference matches openapi.json", async () => {
const files = await render()
// Bun.Glob yields native separators, so Windows lists `api\session.md` where render() keys `api/session.md`.
const current = (await Array.fromAsync(new Bun.Glob("**/*.md").scan({ cwd: directory }))).map((file) =>
file.split(path.sep).join("/"),
)
expect(current.toSorted()).toEqual(Object.keys(files).toSorted())
for (const [file, content] of Object.entries(files)) {
// Run `bun run generate` from packages/protocol (or `bun run generate:api-skill` from packages/core) when this fails.
expect(await Bun.file(path.join(directory, file)).text()).toBe(content)
}
})