thinking.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { describe, expect, test } from "bun:test"
  2. import { reasoningSummary } from "../../../src/context/thinking"
  3. describe("reasoningSummary", () => {
  4. test("extracts a leading summary title and leaves markdown body", () => {
  5. expect(reasoningSummary("**Continuing Quality Review**\n\nDetails.\n\n**Next section**\n\nMore.")).toEqual({
  6. title: "Continuing Quality Review",
  7. body: "Details.\n\n**Next section**\n\nMore.",
  8. })
  9. })
  10. test("extracts a completed title before its streamed body arrives", () => {
  11. expect(reasoningSummary("**Continuing Quality Review**")).toEqual({
  12. title: "Continuing Quality Review",
  13. body: "",
  14. })
  15. })
  16. test("preserves markdown-significant indentation in the extracted body", () => {
  17. expect(reasoningSummary("**Continuing Quality Review**\n\n const value = true\n")).toEqual({
  18. title: "Continuing Quality Review",
  19. body: " const value = true",
  20. })
  21. })
  22. test("does not consume ordinary leading bold content", () => {
  23. expect(reasoningSummary("**Important:** keep this in the body.")).toEqual({
  24. title: null,
  25. body: "**Important:** keep this in the body.",
  26. })
  27. })
  28. test("leaves content without a leading title in its body", () => {
  29. expect(reasoningSummary("Details only.")).toEqual({ title: null, body: "Details only." })
  30. })
  31. })