mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-17 12:56:41 +02:00
add test
This commit is contained in:
@@ -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