mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 14:27:40 +00:00
* 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
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { describe } from "vitest"
|
|
import { LGraph, LiteGraph } from "@/litegraph"
|
|
import { lgTest } from "./lgTest"
|
|
|
|
describe.concurrent("LGraph", () => {
|
|
lgTest("can be instantiated", ({ expect }) => {
|
|
// @ts-expect-error Intentional - extra holds any / all consumer data that should be serialised
|
|
const graph = new LGraph({ extra: "TestGraph" })
|
|
expect(graph).toBeInstanceOf(LGraph)
|
|
expect(graph.extra).toBe("TestGraph")
|
|
expect(graph.extra).toBe("TestGraph")
|
|
})
|
|
|
|
lgTest("populates optional values", ({ expect, minimalSerialisableGraph }) => {
|
|
const dGraph = new LGraph(minimalSerialisableGraph)
|
|
expect(dGraph.links).toBeInstanceOf(Map)
|
|
expect(dGraph.nodes).toBeInstanceOf(Array)
|
|
expect(dGraph.groups).toBeInstanceOf(Array)
|
|
})
|
|
|
|
lgTest("matches previous snapshot", ({ expect, minimalSerialisableGraph, basicSerialisableGraph }) => {
|
|
const minLGraph = new LGraph(minimalSerialisableGraph)
|
|
expect(minLGraph).toMatchSnapshot("minLGraph")
|
|
const basicLGraph = new LGraph(basicSerialisableGraph)
|
|
expect(basicLGraph).toMatchSnapshot("basicLGraph")
|
|
})
|
|
})
|
|
|
|
describe.concurrent("Legacy LGraph Compatibility Layer", () => {
|
|
lgTest("can be extended via prototype", ({ expect, minimalGraph }) => {
|
|
// @ts-expect-error Should always be an error.
|
|
LGraph.prototype.newMethod = function () {
|
|
return "New method added via prototype"
|
|
}
|
|
// @ts-expect-error Should always be an error.
|
|
expect(minimalGraph.newMethod()).toBe("New method added via prototype")
|
|
})
|
|
|
|
lgTest("is correctly assigned to LiteGraph", ({ expect }) => {
|
|
expect(LiteGraph.LGraph).toBe(LGraph)
|
|
})
|
|
})
|