Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import { describe, expect, it,} from '@monochromatic-dev/module-test/ts';
import { assistantContentText, extractLastAssistantText, isAssistantMessage, isTextBlock,} from './message-extract.ts';
await describe({ name: '', children: [ describe({ name: isTextBlock.name, children: [ it({ name: 'accepts text blocks and rejects other content', fn: async function testTextBlockGuard() { expect(isTextBlock({ type: 'text', text: 'hello', },),).toBe(true,); expect(isTextBlock({ type: 'thinking', thinking: 'hmm', },),).toBe(false,); }, },), ], },), describe({ name: isAssistantMessage.name, children: [ it({ name: 'accepts assistant messages with string or array content', fn: async function testAssistantGuard() { expect(isAssistantMessage({ role: 'assistant', content: 'hello', },),).toBe(true,); expect(isAssistantMessage({ role: 'assistant', content: [], },),).toBe(true,); expect(isAssistantMessage({ role: 'user', content: 'hello', },),).toBe(false,); }, },), ], },), describe({ name: assistantContentText.name, children: [ it({ name: 'returns string content unchanged', fn: async function testStringContent() { expect(assistantContentText('hello',),).toBe('hello',); }, },), it({ name: 'joins only text blocks from array content', fn: async function testArrayContent() { expect(assistantContentText([ { type: 'thinking', thinking: 'hidden', }, { type: 'text', text: 'first', }, { type: 'text', text: 'second', }, ],),).toBe('first\nsecond',); }, },), ], },), describe({ name: extractLastAssistantText.name, children: [ it({ name: 'returns newest assistant text', fn: async function testNewestAssistantText() { expect(extractLastAssistantText([ { role: 'assistant', content: [{ type: 'text', text: 'old', },], }, { role: 'user', content: 'ignored', }, { role: 'assistant', content: [{ type: 'text', text: 'new', },], }, ],),).toBe('new',); }, },), it({ name: 'returns empty string when no assistant text exists', fn: async function testNoAssistantText() { expect(extractLastAssistantText([ { role: 'user', content: 'ignored', }, { role: 'assistant', content: [{ type: 'thinking', thinking: 'hidden', },], }, ],),).toBe('',); }, },), ], },), ],},);