KeiSeiKit-1.0/_ts_packages/packages/gmail-adapter/test/tools.test.ts
Parfii-bot a4e667de10 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

43 lines
1.6 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { GmailClient, type GmailSurface } from "../src/client.js";
import { buildGmailTools } from "../src/tools.js";
function mkSurface(): GmailSurface {
return {
list: vi.fn(async () => [{ id: "m1" }]),
get: vi.fn(async () => ({ id: "m1", snippet: "hello", payload: { headers: [] } })),
modify: vi.fn(async () => undefined),
trash: vi.fn(async () => undefined),
};
}
describe("gmail tool surface", () => {
it("registers 6 tools", () => {
const c = new GmailClient({ clientId: "", clientSecret: "", refreshToken: "", gmailSurface: mkSurface() });
const names = buildGmailTools(c).map((t) => t.name);
expect(names).toEqual([
"gmail_list_unread",
"gmail_get_message",
"gmail_search",
"gmail_label_message",
"gmail_archive",
"gmail_trash",
]);
});
it("gmail_list_unread formats empty list", async () => {
const surface: GmailSurface = { ...mkSurface(), list: vi.fn(async () => []) };
const c = new GmailClient({ clientId: "", clientSecret: "", refreshToken: "", gmailSurface: surface });
const tool = buildGmailTools(c).find((t) => t.name === "gmail_list_unread");
const out = await tool!.handler({});
expect(out).toBe("No messages.");
});
it("gmail_trash returns ok string", async () => {
const surface = mkSurface();
const c = new GmailClient({ clientId: "", clientSecret: "", refreshToken: "", gmailSurface: surface });
const tool = buildGmailTools(c).find((t) => t.name === "gmail_trash");
const out = await tool!.handler({ id: "m1" });
expect(out).toContain("trashed m1");
});
});