Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

client.test.ts

39 lines1.1 KB

1import { describe, expect, it } from 'vitest'
2import { resolveCohereTransport } from '../src/utils/client'
3​
4describe('resolveCohereTransport', () => {
5 it('defaults to api.cohere.com with no headers', () => {
6 expect(resolveCohereTransport({ apiKey: 'k' })).toEqual({
7 baseUrl: 'https://api.cohere.com',
8 headers: {},
9 })
10 })
11​
12 it('maps baseURL and defaultHeaders', () => {
13 expect(
14 resolveCohereTransport({
15 apiKey: 'k',
16 baseURL: 'https://gw.example/cohere/',
17 defaultHeaders: { 'cf-aig-authorization': 'Bearer t' },
18 }),
19 ).toEqual({
20 baseUrl: 'https://gw.example/cohere',
21 headers: { 'cf-aig-authorization': 'Bearer t' },
22 })
23 })
24​
25 it('keeps baseUrl and headers working, normalized names win', () => {
26 expect(
27 resolveCohereTransport({
28 apiKey: 'k',
29 baseUrl: 'https://old.example',
30 headers: { a: '1', b: 'old' },
31 baseURL: 'https://new.example',
32 defaultHeaders: { b: 'new' },
33 }),
34 ).toEqual({
35 baseUrl: 'https://new.example',
36 headers: { b: 'new' },
37 })
38 })
39})