Open History to see the last commit
1import { afterEach, expect, it } from 'vitest'
2import docs from './fixtures/gemini-native-audio-thinking.json'
3import {
4 geminiNativeAudioThinking,
5 parseGeminiNativeAudioThinking,
6} from './gemini-live-thinking.ts'
7
8const originalFetch = globalThis.fetch
9afterEach(() => {
10 globalThis.fetch = originalFetch
11})
12it('sources exact native audio budget mode and disable semantics without bounds guesses', () => {
13 expect(parseGeminiNativeAudioThinking(docs.markdown)).toEqual({
14 rawId: 'gemini-2.5-flash-native-audio-preview-12-2025',
15 reasoning: { mode: 'budget', mandatory: false },
16 })
17 expect(() =>
18 parseGeminiNativeAudioThinking('```\n' + docs.markdown + '\n```'),
19 ).toThrow()
20 expect(() =>
21 parseGeminiNativeAudioThinking(
22 docs.markdown.replace(
23 'You can disable thinking by setting',
24 'You cannot disable thinking by setting',
25 ),
26 ),
27 ).toThrow()
28})
29it('uses model names only to select own guide; exact binding excludes latest aliases', async () => {
30 globalThis.fetch = async () => new Response(docs.markdown)
31 const parsed = await geminiNativeAudioThinking([
32 'gemini-2.5-flash-native-audio-latest',
33 ])
34 expect(parsed?.rawId).toBe('gemini-2.5-flash-native-audio-preview-12-2025')
35 expect(parsed?.rawId).not.toBe('gemini-2.5-flash-native-audio-latest')
36})
37it('fails clearly when the native source cannot be read', async () => {
38 globalThis.fetch = async () => new Response('unavailable', { status: 503 })
39 await expect(
40 geminiNativeAudioThinking([
41 'gemini-2.5-flash-native-audio-preview-12-2025',
42 ]),
43 ).rejects.toThrow('503')
44})
45
46it('rejects positive instruction text embedded in negated prose', () => {
47 for (const phrase of [
48 'The latest native audio output model',
49 'The `thinkingBudget` parameter guides',
50 'You can disable thinking by setting',
51 ]) {
52 expect(() =>
53 parseGeminiNativeAudioThinking(
54 docs.markdown.replace(phrase, 'Do not assume ' + phrase),
55 ),
56 ).toThrow()
57 }
58})