add test
This commit is contained in:
parent
81e8cb81a5
commit
7141d76e1c
1 changed files with 29 additions and 0 deletions
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)
|
||||||
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue