import { describe, expect, test } from "vitest"; import { extractThinkingMarkup, getReasoningText, isReasoningStreaming, } from "./transforms"; import type { ConversationMessage } from "./types"; const message = (parts: ConversationMessage["parts"]): ConversationMessage => ({ id: "message-1", parts, role: "assistant", }); describe("reasoning traces", () => { test("extracts completed and streaming MiniMax think blocks", () => { expect( extractThinkingMarkup( "First thoughtCurrent thought" ) ).toBe("First thought\n\nCurrent thought"); }); test("combines native reasoning with inline thinking", () => { expect( getReasoningText( message([ { state: "streaming", text: "Native thought", type: "reasoning" }, { state: "streaming", text: "Inline thought", type: "text" }, ]) ) ).toBe("Native thought\n\nInline thought"); }); test("recognizes an open streamed think block as live reasoning", () => { expect( isReasoningStreaming( message([{ state: "streaming", text: "Working", type: "text" }]) ) ).toBe(true); }); });