File size: 1,022 Bytes
6132f30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { describe, expect, it } from "vitest";
import { splitResponseShellMarkdown } from "./responseShellMarkdown";

describe("splitResponseShellMarkdown", () => {
  it("splits Result/Why/Next action sections", () => {
    const input = [
      "**Result**",
      "The main answer.",
      "",
      "**Why**",
      "- Reason one",
      "- Reason two",
      "",
      "**Next action**",
      "- Follow-up",
    ].join("\n");
    const out = splitResponseShellMarkdown(input);
    expect(out.hasShell).toBe(true);
    expect(out.result).toContain("The main answer.");
    expect(out.why).toContain("Reason one");
    expect(out.nextAction).toContain("Follow-up");
    expect(out.rest).toBe("");
  });

  it("falls back when no shell headings are present", () => {
    const out = splitResponseShellMarkdown("Plain markdown content only.");
    expect(out.hasShell).toBe(false);
    expect(out.result).toBe("Plain markdown content only.");
    expect(out.why).toBe("");
    expect(out.nextAction).toBe("");
  });
});