mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 12:11:28 -07:00
test(ai): cover shared client helpers
This commit is contained in:
21
src/ai/client.test.ts
Normal file
21
src/ai/client.test.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
|
||||||
|
import { extractAiText, normalizeOpenAiBaseUrl } from './client';
|
||||||
|
|
||||||
|
test('normalizeOpenAiBaseUrl appends v1 when missing', () => {
|
||||||
|
assert.equal(normalizeOpenAiBaseUrl('https://openrouter.ai/api'), 'https://openrouter.ai/api/v1');
|
||||||
|
assert.equal(normalizeOpenAiBaseUrl('https://example.test/v1'), 'https://example.test/v1');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('extractAiText joins OpenAI structured text parts', () => {
|
||||||
|
assert.equal(
|
||||||
|
extractAiText([
|
||||||
|
{ type: 'text', text: 'hello ' },
|
||||||
|
{ type: 'text', text: 'world' },
|
||||||
|
{ type: 'image', text: 'ignored' },
|
||||||
|
]),
|
||||||
|
'hello world',
|
||||||
|
);
|
||||||
|
assert.equal(extractAiText(' plain text '), 'plain text');
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user