Files
llm-wiki/workbench/web/test/graph-reader-request.test.ts
T
2026-07-12 21:26:08 +08:00

33 lines
999 B
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import type { GraphOpenPagePayload } from "@llm-wiki/graph-engine";
import { graphReaderDrawer, shouldApplyGraphReaderResult } from "../src/lib/drawer-state";
describe("graph reader async request guards", () => {
it("only applies a page read result to the matching open graph reader", () => {
const first = graphPayload("a", "wiki/entities/A.md");
const second = graphPayload("b", "wiki/entities/B.md");
assert.equal(shouldApplyGraphReaderResult(graphReaderDrawer(first, { loading: true }), first), true);
assert.equal(shouldApplyGraphReaderResult(graphReaderDrawer(second, { loading: true }), first), false);
});
});
function graphPayload(id: string, path: string): GraphOpenPagePayload {
return {
path,
node: {
id,
title: id.toUpperCase(),
type: "entity",
typeLabel: "实体",
sourcePath: path,
community: "test",
date: null,
source: null,
isolated: false,
},
};
}