Download packages/tui/test/prompt/display.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 2.09 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/test/prompt/display.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/tui/test/prompt/display.test.ts
-
curl -L -o display.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/test/prompt/display.test.ts
2.09 kB
| import { describe, expect, test } from "bun:test" | |
| import { displayCharAt, displaySlice, mentionTriggerIndex } from "../../src/prompt/display" | |
| describe("prompt display", () => { | |
| test("uses display-width offsets for mentions", () => { | |
| expect(mentionTriggerIndex("@")).toBe(0) | |
| expect(mentionTriggerIndex("test @")).toBe(5) | |
| expect(mentionTriggerIndex("δΈζ @")).toBe(5) | |
| expect(mentionTriggerIndex("γγγ«γ‘γ― @")).toBe(11) | |
| expect(mentionTriggerIndex("νκ΅μ΄ @")).toBe(7) | |
| expect(mentionTriggerIndex("π @")).toBe(3) | |
| expect(mentionTriggerIndex("δΈζ @src file", Bun.stringWidth("δΈζ @src"))).toBe(5) | |
| expect(displayCharAt("δΈζ @src", Bun.stringWidth("δΈζ @"))).toBe("s") | |
| expect(displaySlice("δΈζ @src", 5, Bun.stringWidth("δΈζ @src"))).toBe("@src") | |
| expect(displaySlice("δΈζ @src", 6, Bun.stringWidth("δΈζ @src"))).toBe("src") | |
| expect(mentionTriggerIndex("π¨βπ©βπ§βπ¦ @src", Bun.stringWidth("π¨βπ©βπ§βπ¦ @src"))).toBe(3) | |
| expect(displayCharAt("π¨βπ©βπ§βπ¦ @src", Bun.stringWidth("π¨βπ©βπ§βπ¦ @"))).toBe("s") | |
| expect(displaySlice("π¨βπ©βπ§βπ¦ @src", 3, Bun.stringWidth("π¨βπ©βπ§βπ¦ @src"))).toBe("@src") | |
| expect(mentionTriggerIndex("@file1\n@file2", 13)).toBe(7) | |
| expect(displayCharAt("@file1\n@file2", 6)).toBe("\n") | |
| expect(displaySlice("@file1\n@file2", 8, 13)).toBe("file2") | |
| expect(mentionTriggerIndex("@file1\nfoo @file2", 17)).toBe(11) | |
| expect(mentionTriggerIndex("δΈζ @one\n@two", 14)).toBe(10) | |
| expect(displaySlice("δΈζ @one\n@two", 11, 14)).toBe("two") | |
| expect(mentionTriggerIndex("δΈζ@")).toBeUndefined() | |
| expect(mentionTriggerIndex("γγγ«γ‘γ―@")).toBeUndefined() | |
| expect(mentionTriggerIndex("νκ΅μ΄@")).toBeUndefined() | |
| expect(mentionTriggerIndex("π@")).toBeUndefined() | |
| expect(mentionTriggerIndex("hello@")).toBeUndefined() | |
| expect(mentionTriggerIndex("foo@bar.com")).toBeUndefined() | |
| expect(mentionTriggerIndex("δΈζ @src file")).toBeUndefined() | |
| }) | |
| }) | |