Files
AirCoding/packages/opencode/test/util/timeout.test.ts
airlongdian 9ea05df273 fix: 修正 logo 中 N 和 G 字母造型
N 添加对角线笔画(█▄ █),G 添加内横杠(█ ▀█),
避免与 O 字母造型雷同。同步更新 ui.ts 中的硬编码 wordmark。
2026-06-14 09:48:03 +08:00

22 lines
702 B
TypeScript

import { describe, expect, test } from "bun:test"
import { withTimeout } from "../../src/util/timeout"
describe("util.timeout", () => {
test("should resolve when promise completes before timeout", async () => {
const fastPromise = new Promise<string>((resolve) => {
setTimeout(() => resolve("fast"), 10)
})
const result = await withTimeout(fastPromise, 100)
expect(result).toBe("fast")
})
test("should reject when promise exceeds timeout", async () => {
const slowPromise = new Promise<string>((resolve) => {
setTimeout(() => resolve("slow"), 200)
})
await expect(withTimeout(slowPromise, 50)).rejects.toThrow("Operation timed out after 50ms")
})
})