forked from mem9-ai/mem9
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplant-dialog-content.test.ts
More file actions
64 lines (60 loc) · 1.63 KB
/
plant-dialog-content.test.ts
File metadata and controls
64 lines (60 loc) · 1.63 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { describe, expect, it } from "vitest";
import type { Memory } from "@/types/memory";
import { buildPixelFarmPlantDialogEntries } from "./plant-dialog-content";
function createMemory(id: string, content: string): Memory {
return {
id,
content,
memory_type: "pinned",
source: "test",
tags: ["Work"],
metadata: null,
agent_id: "agent-1",
session_id: "session-1",
state: "active",
version: 1,
updated_by: "tester",
created_at: "2026-04-05T00:00:00.000Z",
updated_at: "2026-04-05T00:00:00.000Z",
};
}
describe("plant-dialog-content", () => {
it("prepends one intro entry before the real plant memories", () => {
const entries = buildPixelFarmPlantDialogEntries({
bucketTotalMemoryCount: 12,
memories: [
createMemory("m1", "First memory"),
createMemory("m2", "Second memory"),
],
tagLabel: "Work",
t: (key, vars) => `${key}:${JSON.stringify(vars ?? {})}`,
});
expect(entries).toEqual([
{
id: "plant-intro:Work:12",
kind: "intro",
content: "pixel_farm.plant_dialog.intro:{\"tag\":\"Work\",\"count\":12}",
},
{
id: "m1",
kind: "memory",
content: "First memory",
memoryOffset: 0,
},
{
id: "m2",
kind: "memory",
content: "Second memory",
memoryOffset: 1,
},
]);
});
it("returns no dialog entries when a plant has no real memories", () => {
expect(buildPixelFarmPlantDialogEntries({
bucketTotalMemoryCount: 12,
memories: [],
tagLabel: "Work",
t: (key) => key,
})).toEqual([]);
});
});