Files
smartai/test/test.research.ts

65 lines
2.0 KiB
TypeScript
Raw Permalink Normal View History

import { tap, expect } from '@push.rocks/tapbundle';
import * as smartai from '../ts/index.js';
// Test the research capabilities
tap.test('OpenAI research method should exist', async () => {
const openaiProvider = new smartai.OpenAiProvider({
openaiToken: 'test-token'
});
// Check that the research method exists
expect(typeof openaiProvider.research).toEqual('function');
});
tap.test('Anthropic research method should exist', async () => {
const anthropicProvider = new smartai.AnthropicProvider({
anthropicToken: 'test-token'
});
// Check that the research method exists
expect(typeof anthropicProvider.research).toEqual('function');
});
tap.test('Research interfaces should be exported', async () => {
// Check that the types are available (they won't be at runtime but TypeScript will check)
const testResearchOptions: smartai.ResearchOptions = {
query: 'test query',
searchDepth: 'basic'
};
expect(testResearchOptions).toBeInstanceOf(Object);
expect(testResearchOptions.query).toEqual('test query');
});
tap.test('Perplexity provider should have research method', async () => {
const perplexityProvider = new smartai.PerplexityProvider({
perplexityToken: 'test-token'
});
// For Perplexity, we actually implemented it, so let's just check it exists
expect(typeof perplexityProvider.research).toEqual('function');
});
tap.test('Other providers should have research stubs', async () => {
const groqProvider = new smartai.GroqProvider({
groqToken: 'test-token'
});
const ollamaProvider = new smartai.OllamaProvider({});
// Check that the research method exists and throws error
expect(typeof groqProvider.research).toEqual('function');
expect(typeof ollamaProvider.research).toEqual('function');
// Test that they throw errors when called
let errorCaught = false;
try {
await groqProvider.research({ query: 'test' });
} catch (error) {
errorCaught = true;
expect(error.message).toInclude('not yet supported');
}
expect(errorCaught).toBeTrue();
});
export default tap.start();