feat: Add testing framework and initial test cases for various tools and database operations

This commit is contained in:
ethan.chen
2026-01-07 10:05:04 +08:00
parent 372b52b214
commit 47ecc40186
23 changed files with 1781 additions and 40 deletions

View File

@@ -0,0 +1,61 @@
/**
* Football tools tests
*/
import { describe, test, expect, beforeEach } from "bun:test";
import { registerFootballTools } from "../../../../src/tools/hobbies/football.js";
import { callTool } from "../../../helpers/tool-helper.js";
import { setTestEnv } from "../../../helpers/test-utils.js";
describe("Football Tools", () => {
let cleanupEnv: () => void;
beforeEach(() => {
cleanupEnv = setTestEnv({
FOOTBALL_API_KEY: "test-key",
});
registerFootballTools();
});
afterEach(() => {
cleanupEnv();
});
test("should get football matches", async () => {
const result = await callTool("football_matches", {
days: 7,
});
// Should return matches or placeholder message
expect(result.content[0].text).toBeDefined();
expect(result.content[0].text.length).toBeGreaterThan(0);
});
test("should get team information", async () => {
const result = await callTool("football_team_info", {
team: "Manchester United",
});
// Should return team info or placeholder
expect(result.content[0].text).toBeDefined();
});
test("should get league standings", async () => {
const result = await callTool("football_standings", {
league: "Premier League",
});
// Should return standings or placeholder
expect(result.content[0].text).toBeDefined();
});
test("should handle missing API key gracefully", async () => {
cleanupEnv();
cleanupEnv = setTestEnv({});
registerFootballTools();
const result = await callTool("football_matches", {});
expect(result.content[0].text).toContain("FOOTBALL_API_KEY");
});
});