basant307/AI_Governance_Project
048
1/**2 * @license3 * Copyright 2026 Qwen4 * SPDX-License-Identifier: Apache-2.05 */6 7import { describe, expect, it } from 'vitest';8import type { Part } from '@google/genai';9import {10 MID_TURN_USER_MESSAGE_PREFIX,11 prefixMidTurnUserMessageParts,12} from './midTurnUserMessage.js';13 14describe('prefixMidTurnUserMessageParts', () => {15 it('returns a text-only part when parts normalize to empty', () => {16 expect(prefixMidTurnUserMessageParts([], 'fallback')).toEqual([17 { text: `${MID_TURN_USER_MESSAGE_PREFIX}fallback` },18 ]);19 });20 21 it('prepends the prefix to the first text part', () => {22 const parts: Part[] = [{ text: 'hello' }, { text: 'world' }];23 24 expect(prefixMidTurnUserMessageParts(parts, 'hello')).toEqual([25 { text: `${MID_TURN_USER_MESSAGE_PREFIX}hello` },26 { text: 'world' },27 ]);28 });29 30 it('prepends a text prefix before non-text first parts', () => {31 const imagePart: Part = {32 inlineData: { mimeType: 'image/png', data: 'abc' },33 };34 35 expect(prefixMidTurnUserMessageParts([imagePart], 'inspect this')).toEqual([36 { text: `${MID_TURN_USER_MESSAGE_PREFIX}inspect this` },37 imagePart,38 ]);39 });40});41 