tui-composer-display.test.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { describe, expect, it } from "vitest";
  2. import { renderComposerDisplay } from "../tui/composer-display.js";
  3. describe("tui composer display", () => {
  4. it("renders placeholder when empty", () => {
  5. expect(renderComposerDisplay("", "Ask InkOS", false)).toEqual({
  6. textBeforeCursor: "Ask InkOS",
  7. textAfterCursor: "",
  8. cursor: "",
  9. isPlaceholder: true,
  10. });
  11. });
  12. it("keeps the initial caret before the placeholder text", () => {
  13. expect(renderComposerDisplay("", "Ask InkOS", true)).toEqual({
  14. textBeforeCursor: "",
  15. textAfterCursor: "Ask InkOS",
  16. cursor: "│",
  17. isPlaceholder: true,
  18. });
  19. });
  20. it("renders plain input text with a blinking bar cursor when active", () => {
  21. expect(renderComposerDisplay("continue", "Ask InkOS", true)).toEqual({
  22. textBeforeCursor: "continue",
  23. textAfterCursor: "",
  24. cursor: "│",
  25. isPlaceholder: false,
  26. });
  27. });
  28. it("hides the cursor between blink frames", () => {
  29. expect(renderComposerDisplay("continue", "Ask InkOS", false)).toEqual({
  30. textBeforeCursor: "continue",
  31. textAfterCursor: "",
  32. cursor: "",
  33. isPlaceholder: false,
  34. });
  35. });
  36. });