Files
ComfyUI_frontend/test/serialise.test.ts
filtered 7e21b00cc7 Replace test framework: jest -> vitest (#281)
* Replace test framework: jest -> vitest

* nit - remove deprecated npm scripts

* Add vitest config

* Add a few basic tests

* Update actions with vitest params

* Add correct expectations

* Remove jest config
2024-11-06 17:27:32 -05:00

28 lines
978 B
TypeScript

import { describe } from "vitest"
import { LGraph, LGraphGroup, LGraphNode } from "@/litegraph"
import { lgTest } from "./lgTest"
import type { ISerialisedGraph } from "@/types/serialisation"
describe.concurrent("LGraph Serialisation", () => {
lgTest("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)
})
})