25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs/promises";
|
|
import test from "node:test";
|
|
import { createProject, projectRoot, updateProject } from "../lib/storage";
|
|
|
|
test("creates a top-level content project and saves its shared recipe", async (t) => {
|
|
const project = await createProject({ name: "测试内容项目" });
|
|
t.after(() => fs.rm(projectRoot(project.id), { recursive: true, force: true }));
|
|
|
|
assert.match(project.id, /^project-[a-f0-9]{6}$/);
|
|
assert.equal(project.recipe.tone, "真诚自然");
|
|
|
|
const updated = await updateProject(project.id, {
|
|
revision: project.revision,
|
|
description: "固定方式生成同类内容",
|
|
recipe: { audience: "第一次做内容的创作者", defaultTags: ["内容创作"] },
|
|
});
|
|
|
|
assert.equal(updated.revision, 2);
|
|
assert.equal(updated.description, "固定方式生成同类内容");
|
|
assert.equal(updated.recipe.audience, "第一次做内容的创作者");
|
|
assert.deepEqual(updated.recipe.defaultTags, ["内容创作"]);
|
|
assert.equal(updated.recipe.contentFormat, "干货教程");
|
|
});
|