chore(lint): reduce warning debt across core adapters and model clients

This commit is contained in:
William Valentin
2026-02-15 23:03:42 -08:00
parent 92da407e22
commit 49b752e8b0
17 changed files with 239 additions and 117 deletions
+21 -9
View File
@@ -1,4 +1,4 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi } from 'vitest';
import { ModelRouter } from './router.js';
import type { ModelClient, ChatResponse, ChatStreamEvent } from './types.js';
@@ -314,10 +314,13 @@ describe('setClient and labels', () => {
const newFastClient = router.getClient('fast');
expect(newFastClient).toBeDefined();
if (!newFastClient) {
throw new Error('Expected fast client to be set');
}
await router.chat({ messages: [{ role: 'user', content: 'Test' }] }, 'fast');
expect(newFastClient!.chat).toHaveBeenCalled();
expect(newFastClient!.chat).toHaveBeenCalledTimes(1);
expect(newFastClient.chat).toHaveBeenCalled();
expect(newFastClient.chat).toHaveBeenCalledTimes(1);
expect(mockClient1.chat).toHaveBeenCalledTimes(1);
});
@@ -336,10 +339,13 @@ describe('setClient and labels', () => {
const newClient = router.getClient('complex');
expect(newClient).toBe(mockClient2);
if (!newClient) {
throw new Error('Expected complex client to be set');
}
await router.chat({ messages: [{ role: 'user', content: 'Test' }] }, 'complex');
expect(newClient!.chat).toHaveBeenCalled();
expect(newClient.chat).toHaveBeenCalled();
});
it('getLabel returns the label set by setClient', () => {
@@ -424,19 +430,25 @@ describe('setClient and labels', () => {
const initialFastClient = router.getClient('fast');
expect(initialFastClient).toBeDefined();
if (!initialFastClient) {
throw new Error('Expected initial fast client to exist');
}
await router.chat({ messages: [{ role: 'user', content: 'Test' }] }, 'fast');
expect(initialFastClient!.chat).toHaveBeenCalled();
expect(initialFastClient!.chat).toHaveBeenCalledTimes(1);
expect(initialFastClient.chat).toHaveBeenCalled();
expect(initialFastClient.chat).toHaveBeenCalledTimes(1);
router.setClient('fast', mockClient2, 'fast-replaced');
const newFastClient = router.getClient('fast');
if (!newFastClient) {
throw new Error('Expected replaced fast client to exist');
}
await router.chat({ messages: [{ role: 'user', content: 'Test' }] }, 'fast');
expect(newFastClient!.chat).toHaveBeenCalled();
expect(newFastClient!.chat).toHaveBeenCalledTimes(1);
expect(initialFastClient!.chat).toHaveBeenCalledTimes(1);
expect(newFastClient.chat).toHaveBeenCalled();
expect(newFastClient.chat).toHaveBeenCalledTimes(1);
expect(initialFastClient.chat).toHaveBeenCalledTimes(1);
});
it('strict tier mode disables fallback chain for that tier', async () => {