paste-summary.test.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { describe, expect, it } from "bun:test"
  2. import { shouldSummarize } from "../../src/kilocode/paste-summary"
  3. describe("paste-summary", () => {
  4. it("does not summarize 4 lines", () => {
  5. const text = Array.from({ length: 4 }, (_, i) => `line ${i + 1}`).join("\n")
  6. expect(shouldSummarize(text)).toEqual({ lines: 4, summarize: false })
  7. })
  8. it("summarizes 5 lines", () => {
  9. const text = Array.from({ length: 5 }, (_, i) => `line ${i + 1}`).join("\n")
  10. expect(shouldSummarize(text)).toEqual({ lines: 5, summarize: true })
  11. })
  12. it("does not summarize 800 chars", () => {
  13. const text = "a".repeat(800)
  14. expect(shouldSummarize(text)).toEqual({ lines: 1, summarize: false })
  15. })
  16. it("summarizes 801 chars", () => {
  17. const text = "a".repeat(801)
  18. expect(shouldSummarize(text)).toEqual({ lines: 1, summarize: true })
  19. })
  20. it("summarizes when either threshold triggers independently", () => {
  21. const lines = Array.from({ length: 5 }, () => "a").join("\n")
  22. const chars = "b".repeat(801)
  23. expect(shouldSummarize(lines)).toEqual({ lines: 5, summarize: true })
  24. expect(shouldSummarize(chars)).toEqual({ lines: 1, summarize: true })
  25. })
  26. it("keeps 4 lines and 780 chars expanded", () => {
  27. const row = "a".repeat(194)
  28. const text = Array.from({ length: 4 }, () => row).join("\n")
  29. expect(text.length).toBe(779)
  30. expect(shouldSummarize(text)).toEqual({ lines: 4, summarize: false })
  31. })
  32. it("summarizes 5 lines and 500 chars", () => {
  33. const row = "b".repeat(96)
  34. const text = Array.from({ length: 5 }, () => row).join("\n")
  35. expect(text.length).toBe(484)
  36. expect(shouldSummarize(text)).toEqual({ lines: 5, summarize: true })
  37. })
  38. })