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('binds the Model comparison thinkingBudget column to its linked native audio id', () => {
13 // The guide no longer says thinking can be disabled: mandatory is unstated.
14 expect(parseGeminiNativeAudioThinking(docs.markdown)).toEqual({
15 rawId: 'gemini-2.5-flash-native-audio-preview-12-2025',
16 reasoning: { mode: 'budget', mandatory: null },
17 })
18 expect(() =>
19 parseGeminiNativeAudioThinking('```\n' + docs.markdown + '\n```'),
20 ).toThrow()
21})
22it('throws when the thinkingBudget column is not exactly one native audio model', () => {
23 // A second column that also uses thinkingBudget is ambiguous.
24 expect(() =>
25 parseGeminiNativeAudioThinking(
26 docs.markdown.replace(
27 'Uses `thinkingLevel` (`minimal`',
28 'Uses `thinkingBudget` (`minimal`',
29 ),
30 ),
31 ).toThrow('unreadable')
32 // The column's name must link a native audio model page.
33 expect(() =>
34 parseGeminiNativeAudioThinking(
35 docs.markdown.replace(
36 '/docs/models/gemini-2.5-flash-native-audio-preview-12-2025',
37 '/docs/models/gemini-2.5-flash',
38 ),
39 ),
40 ).toThrow('unreadable')
41})
42it('uses model names only to select own guide; exact binding excludes latest aliases', async () => {
43 globalThis.fetch = async () => new Response(docs.markdown)
44 const parsed = await geminiNativeAudioThinking([
45 'gemini-2.5-flash-native-audio-latest',
46 ])
47 expect(parsed?.rawId).toBe('gemini-2.5-flash-native-audio-preview-12-2025')
48 expect(parsed?.rawId).not.toBe('gemini-2.5-flash-native-audio-latest')
49})
50it('fails clearly when the native source cannot be read', async () => {
51 globalThis.fetch = async () => new Response('unavailable', { status: 503 })
52 await expect(
53 geminiNativeAudioThinking([
54 'gemini-2.5-flash-native-audio-preview-12-2025',
55 ]),
56 ).rejects.toThrow('503')
57})