renderer.test.ts 729 B

123456789101112131415161718192021222324252627282930
  1. import { expect, test } from "bun:test"
  2. import { destroyRenderer } from "../../src/util/renderer"
  3. test("clears the terminal title before destroying the renderer", () => {
  4. const calls: string[] = []
  5. destroyRenderer({
  6. isDestroyed: false,
  7. setTerminalTitle(title) {
  8. calls.push(`title:${title}`)
  9. },
  10. destroy() {
  11. calls.push("destroy")
  12. },
  13. })
  14. expect(calls).toEqual(["title:", "destroy"])
  15. })
  16. test("still clears the title after renderer destruction", () => {
  17. const calls: string[] = []
  18. destroyRenderer({
  19. isDestroyed: true,
  20. setTerminalTitle(title) {
  21. calls.push(`title:${title}`)
  22. },
  23. destroy() {
  24. calls.push("destroy")
  25. },
  26. })
  27. expect(calls).toEqual(["title:"])
  28. })