Open History to see the last commit
1import { beforeEach, describe, expect, it, vi } from 'vitest'
2import { createMistralClient } from '../src/utils/client'
3
4const constructorSpy = vi.hoisted(() =>
5 vi.fn<(options: Record<string, unknown>) => void>(),
6)
7
8vi.mock('@mistralai/mistralai', () => ({
9 Mistral: class {
10 constructor(options: Record<string, unknown>) {
11 constructorSpy(options)
12 }
13 },
14 HTTPClient: class {
15 addHook() {}
16 },
17}))
18
19describe('createMistralClient', () => {
20 beforeEach(() => {
21 constructorSpy.mockClear()
22 })
23
24 it('maps baseURL onto serverURL', () => {
25 createMistralClient({ apiKey: 'k', baseURL: 'https://gw.example/mistral' })
26 expect(constructorSpy).toHaveBeenCalledExactlyOnceWith({
27 apiKey: 'k',
28 serverURL: 'https://gw.example/mistral',
29 })
30 })
31
32 it('keeps serverURL working, baseURL wins', () => {
33 createMistralClient({
34 apiKey: 'k',
35 serverURL: 'https://old.example',
36 baseURL: 'https://new.example',
37 })
38 expect(constructorSpy).toHaveBeenCalledExactlyOnceWith({
39 apiKey: 'k',
40 serverURL: 'https://new.example',
41 })
42 })
43})