File size: 1,654 Bytes
36277c7
4ce05b9
36277c7
 
 
 
 
 
 
 
 
 
4ce05b9
36277c7
 
 
 
 
 
 
 
 
 
4ce05b9
 
 
 
 
 
 
 
 
 
 
 
 
 
36277c7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { describe, it, expect } from "vitest";
import { renderPersonas, renderModels } from "../src/export/dsh.js";
import type { Persona } from "../src/export/dsh.js";

const personas: Persona[] = [
  { id: "a", name: "Chief", role: "总管", model: "deepseek-flash", color: "deepseek", avatar: '{"shape":"whale"}', instructions: "你是 Chief,总管。" },
  { id: "b", name: "代码 bot", role: "代码", instructions: "你是代码 Bot。" },
];

describe("renderPersonas", () => {
  it("renders every persona with metadata and instructions", () => {
    const md = renderPersonas(personas);
    expect(md).toContain("# 人设档案");
    expect(md).toContain("## Chief");
    expect(md).toContain("- 角色:总管");
    expect(md).toContain("- 模型:deepseek-flash");
    expect(md).toContain("你是 Chief,总管。");
    expect(md).toContain("## 代码 bot");
    expect(md).toContain("你是代码 Bot。");
  });

  it("handles empty persona list", () => {
    const md = renderPersonas([]);
    expect(md).toContain("# 人设档案");
  });
});

describe("renderModels", () => {
  it("renders a model table with effort", () => {
    const md = renderModels([
      { id: "a", name: "Chief", role: "总管", model: "deepseek-flash", effort: "high", instructions: "x" },
      { id: "b", name: "代码 bot", role: "代码", model: "xiaomi/mimo-v2.6-pro", instructions: "y" },
    ]);
    expect(md).toContain("# 模型配置");
    expect(md).toContain("| Chief | 总管 | deepseek-flash | high |");
    expect(md).toContain("| 代码 bot | 代码 | xiaomi/mimo-v2.6-pro | - |");
    expect(md).toContain("deepseek-flash");
  });
});