mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-20 10:59:59 +00:00
add test
This commit is contained in:
29
packages/opencode/test/cli/tui/app.test.ts
Normal file
29
packages/opencode/test/cli/tui/app.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { afterEach, expect, mock, spyOn, test } from "bun:test"
|
||||
import * as Core from "@opentui/core"
|
||||
|
||||
afterEach(() => {
|
||||
mock.restore()
|
||||
})
|
||||
|
||||
test("tui rejects when renderer startup fails", async () => {
|
||||
const err = new Error("setRawMode failed with errno: 9")
|
||||
spyOn(Core, "createCliRenderer").mockRejectedValue(err)
|
||||
|
||||
const { tui } = await import("../../../src/cli/cmd/tui/app")
|
||||
const result = await Promise.race([
|
||||
tui({
|
||||
url: "http://opencode.internal",
|
||||
config: {},
|
||||
args: {
|
||||
continue: false,
|
||||
fork: false,
|
||||
},
|
||||
}).then(
|
||||
() => "resolved",
|
||||
(error) => error,
|
||||
),
|
||||
Bun.sleep(100).then(() => "timeout"),
|
||||
])
|
||||
|
||||
expect(result).toBe(err)
|
||||
})
|
||||
Reference in New Issue
Block a user