audit follow-up: trim image-analyze test lint warnings

This commit is contained in:
William Valentin
2026-02-15 22:54:36 -08:00
parent 803cf1da11
commit 92da407e22
3 changed files with 13 additions and 23 deletions
+4 -16
View File
@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import type { ModelClient, ChatRequest, ChatResponse } from '../../models/types.js';
import type { ModelClient } from '../../models/types.js';
import { createImageAnalyzeTool } from './image-analyze.js';
describe('image.analyze tool', () => {
@@ -242,20 +242,13 @@ describe('image.analyze tool', () => {
});
it('uses custom system message prompt', async () => {
const mockRequest = {
messages: [] as any,
system: '',
maxTokens: 1024,
};
const mockResponse = {
content: 'Analysis complete.',
stopReason: 'end_turn',
usage: { inputTokens: 100, outputTokens: 10 },
};
mockClient.chat = vi.fn().mockResolvedValue(mockResponse).mockImplementationOnce(async (r) => {
return mockResponse;
});
mockClient.chat = vi.fn().mockResolvedValue(mockResponse);
const tool = createImageAnalyzeTool(mockClient);
await tool.execute({
@@ -263,17 +256,12 @@ describe('image.analyze tool', () => {
prompt: 'Analyze the colors.',
});
const callArgs = (mockClient.chat as any).mock.calls[0][0];
const callArgs = vi.mocked(mockClient.chat).mock.calls[0]?.[0] as { system?: string };
expect(callArgs.system).toContain('vision assistant');
expect(callArgs.system).toContain('Analyze the provided image');
});
it('respects maxTokens parameter', async () => {
const mockRequest = {
messages: [] as any,
system: '',
maxTokens: 1024,
};
const mockResponse = {
content: 'Short response',
stopReason: 'end_turn',
@@ -285,7 +273,7 @@ describe('image.analyze tool', () => {
const tool = createImageAnalyzeTool(mockClient);
await tool.execute({ url: 'https://example.com/image.jpg' });
const callArgs = (mockClient.chat as any).mock.calls[0][0];
const callArgs = vi.mocked(mockClient.chat).mock.calls[0]?.[0] as { maxTokens?: number };
expect(callArgs.maxTokens).toBe(1024);
});