KeiSeiKit-1.0/_ts_packages/packages/grok-adapter/test/tools.test.ts
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

36 lines
1.3 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { GrokClient } from "../src/client.js";
import { buildGrokTools } from "../src/tools.js";
function makeFetchMock(payload: unknown): typeof fetch {
return vi.fn(async () => ({
ok: true,
status: 200,
async text() { return JSON.stringify(payload); },
async json() { return payload; },
} as unknown as Response)) as unknown as typeof fetch;
}
describe("grok tools", () => {
it("exposes 2 tools", () => {
const c = new GrokClient({ apiKey: "k", fetchImpl: makeFetchMock({}) });
const tools = buildGrokTools(c);
expect(tools.map((t) => t.name)).toEqual(["grok_research", "grok_imagine"]);
});
it("grok_research validates non-empty query", async () => {
const c = new GrokClient({ apiKey: "k", fetchImpl: makeFetchMock({}) });
const tool = buildGrokTools(c).find((t) => t.name === "grok_research");
await expect(tool!.handler({ query: "" })).rejects.toBeTruthy();
});
it("grok_imagine defaults quality to standard", async () => {
const c = new GrokClient({
apiKey: "k",
fetchImpl: makeFetchMock({ data: [{ url: "u" }] }),
});
const tool = buildGrokTools(c).find((t) => t.name === "grok_imagine");
const out = await tool!.handler({ prompt: "x" });
expect(out).toContain("u");
});
});