audit follow-up: trim image-analyze test lint warnings
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user