Initial commit

This commit is contained in:
2026-07-10 08:31:27 +08:00
commit 2b74c30d36
134 changed files with 21801 additions and 0 deletions

20
tests/book-store.test.ts Normal file
View File

@@ -0,0 +1,20 @@
import { describe, expect, it, beforeAll } from "vitest";
import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
describe("book store", () => {
beforeAll(() => {
process.env.WRITING_AGENT_DATA_DIR = mkdtempSync(
path.join(tmpdir(), "wa-book-test-"),
);
});
it("creates and lists books", async () => {
const { createBook, getBook, listBooks } = await import("../src/book/store.js");
const book = createBook({ title: "测试之书" });
expect(book.id).toBeTruthy();
expect(getBook(book.id)?.title).toBe("测试之书");
expect(listBooks().some((b) => b.id === book.id)).toBe(true);
});
});