mono/packages/kbot/tests/unit/basic.test.ts
2025-04-02 13:04:20 +02:00

64 lines
1.9 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import * as path from 'node:path'
import { sync as exists } from "@polymech/fs/exists"
import {
getDefaultModels,
TEST_BASE_PATH,
TEST_LOGS_PATH,
TEST_PREFERENCES_PATH,
TEST_TIMEOUT,
TestResult,
runTest,
generateTestReport,
getReportPaths
} from './commons'
// Optionally override models for this specific test file
const models = getDefaultModels()
describe('Basic Operations', () => {
let testResults: TestResult[] = []
const TEST_LOG_PATH = getReportPaths('basic', 'json')
const TEST_REPORT_PATH = getReportPaths('basic', 'md')
it.each(models)('should add two numbers with model %s', async (modelName) => {
const result = await runTest(
'add 5 and 3. Return only the number, no explanation.',
'8',
'addition',
modelName,
TEST_LOG_PATH
)
testResults.push(result)
expect(result.result[0]?.trim()?.toLowerCase()).toEqual('8')
}, { timeout: TEST_TIMEOUT })
it.each(models)('should multiply two numbers with model %s', async (modelName) => {
const result = await runTest(
'multiply 8 and 3. Return only the number, no explanation.',
'24',
'multiplication',
modelName,
TEST_LOG_PATH
)
testResults.push(result)
expect(result.result[0]?.trim()?.toLowerCase()).toEqual('24')
}, { timeout: TEST_TIMEOUT })
it.each(models)('should divide two numbers with model %s', async (modelName) => {
const result = await runTest(
'divide 15 by 3. Return only the number, no explanation.',
'5',
'division',
modelName,
TEST_LOG_PATH
)
testResults.push(result)
expect(result.result[0]?.trim()?.toLowerCase()).toEqual('5')
}, { timeout: TEST_TIMEOUT })
it('should generate markdown report', () => {
generateTestReport(testResults, 'Basic Operations Test Results', TEST_REPORT_PATH)
expect(exists(TEST_REPORT_PATH) === 'file').toBe(true)
})
})