File size: 1,588 Bytes
f0634fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import { describe, expect, it } from 'vitest';
import {
IProtocolAdapterRegistry,
ProtocolSchema,
type ProtocolAdapterConfig,
} from '#/llm-adapter/protocol/protocol';
describe('ProtocolSchema', () => {
it('accepts the four real wire protocols', () => {
for (const protocol of [
'anthropic',
'openai',
'openai_responses',
'google-genai',
]) {
expect(ProtocolSchema.parse(protocol)).toBe(protocol);
}
});
it('rejects vendor names and unknown values', () => {
expect(ProtocolSchema.safeParse('kimi').success).toBe(false);
expect(ProtocolSchema.safeParse('vertexai').success).toBe(false);
expect(ProtocolSchema.safeParse('azure').success).toBe(false);
expect(ProtocolSchema.safeParse('').success).toBe(false);
expect(ProtocolSchema.safeParse(42).success).toBe(false);
});
});
describe('ProtocolAdapterConfig', () => {
it('carries a free-form providerType string, unenumerated at parse time', () => {
const config: ProtocolAdapterConfig = {
protocol: 'openai',
providerType: 'vendor-registered-elsewhere',
modelName: 'vendor-model-1',
};
expect(config.providerType).toBe('vendor-registered-elsewhere');
const withoutVendor: ProtocolAdapterConfig = {
protocol: 'anthropic',
modelName: 'claude-sonnet-4',
};
expect(withoutVendor.providerType).toBeUndefined();
});
});
describe('IProtocolAdapterRegistry', () => {
it('keeps the established DI identity', () => {
expect(IProtocolAdapterRegistry.toString()).toBe('protocolAdapterRegistry');
});
});
|