61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import * as path from 'node:path'
|
|
import { sync as exists } from "@polymech/fs/exists"
|
|
import {
|
|
models,
|
|
TEST_BASE_PATH,
|
|
TEST_LOGS_PATH,
|
|
TEST_PREFERENCES_PATH,
|
|
TEST_TIMEOUT,
|
|
TestResult,
|
|
runTest,
|
|
generateTestReport
|
|
} from './commons'
|
|
|
|
const TEST_LOG_PATH = path.resolve(__dirname, './basic.json')
|
|
|
|
describe('Basic Operations', () => {
|
|
let testResults: TestResult[] = []
|
|
|
|
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: 10000 })
|
|
|
|
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: 10000 })
|
|
|
|
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: 10000 })
|
|
|
|
it('should generate markdown report', () => {
|
|
const reportPath = path.resolve(__dirname, './basic-report.md')
|
|
generateTestReport(testResults, 'Basic Operations Test Results', reportPath)
|
|
expect(exists(reportPath) === 'file').toBe(true)
|
|
})
|
|
})
|