KeiSeiKit-1.0/_ts_packages/packages/gmail-adapter/test/client.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

44 lines
1.5 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { GmailClient, type GmailSurface } from "../src/client.js";
function makeSurface(): GmailSurface {
return {
list: vi.fn(async () => [{ id: "m1", threadId: "t1" }, { id: "m2" }]),
get: vi.fn(async (id: string) => ({
id,
snippet: `snip-${id}`,
payload: {
headers: [
{ name: "Subject", value: `subj-${id}` },
{ name: "From", value: "alice@example.com" },
],
},
})),
modify: vi.fn(async () => undefined),
trash: vi.fn(async () => undefined),
};
}
describe("GmailClient", () => {
it("listUnread returns summarized messages", async () => {
const surface = makeSurface();
const c = new GmailClient({ clientId: "", clientSecret: "", refreshToken: "", gmailSurface: surface });
const out = await c.listUnread(10);
expect(out).toHaveLength(2);
expect(out[0]?.subject).toBe("subj-m1");
});
it("labelMessage calls modify with addIds only", async () => {
const surface = makeSurface();
const c = new GmailClient({ clientId: "", clientSecret: "", refreshToken: "", gmailSurface: surface });
await c.labelMessage("m1", "IMPORTANT");
expect(surface.modify).toHaveBeenCalledWith("m1", ["IMPORTANT"], []);
});
it("archive removes INBOX label", async () => {
const surface = makeSurface();
const c = new GmailClient({ clientId: "", clientSecret: "", refreshToken: "", gmailSurface: surface });
await c.archive("m1");
expect(surface.modify).toHaveBeenCalledWith("m1", [], ["INBOX"]);
});
});