Files
ComfyUI_frontend/test/serialise.test.ts
filtered 2c3535c983 [Test] Add integration test: LGraph snapshot (#591)
- Runs basic Litegraph init before performing the snapshot
- Allows a significantly more useful verification of the public API
2025-02-25 08:58:29 +00:00

28 lines
971 B
TypeScript

import { describe } from "vitest"
import { LGraph, LGraphGroup, LGraphNode } from "@/litegraph"
import { test } from "./testExtensions"
import type { ISerialisedGraph } from "@/types/serialisation"
describe("LGraph Serialisation", () => {
test("can (de)serialise node / group titles", ({ expect, minimalGraph }) => {
const nodeTitle = "Test Node"
const groupTitle = "Test Group"
minimalGraph.add(new LGraphNode(nodeTitle))
minimalGraph.add(new LGraphGroup(groupTitle))
expect(minimalGraph.nodes.length).toBe(1)
expect(minimalGraph.nodes[0].title).toEqual(nodeTitle)
expect(minimalGraph.groups.length).toBe(1)
expect(minimalGraph.groups[0].title).toEqual(groupTitle)
const serialised = JSON.stringify(minimalGraph.serialize())
const deserialised = JSON.parse(serialised) as ISerialisedGraph
const copied = new LGraph(deserialised)
expect(copied.nodes.length).toBe(1)
expect(copied.groups.length).toBe(1)
})
})