mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 22:09:55 +00:00
Stylistic plugin falls short in a few areas when it comes to consistent lists and chaining. Replaced some key rules with antfu's personal variants. `eslint` can now be run repo-wide without params.
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import type { ISerialisedGraph, SerialisableGraph } from "../src/types/serialisation"
|
|
|
|
import { test as baseTest } from "vitest"
|
|
|
|
import { LGraph } from "@/LGraph"
|
|
import { LiteGraph } from "@/litegraph"
|
|
|
|
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
|
|
|
|
interface LitegraphFixtures {
|
|
minimalGraph: LGraph
|
|
minimalSerialisableGraph: SerialisableGraph
|
|
oldSchemaGraph: ISerialisedGraph
|
|
}
|
|
|
|
/** These fixtures alter global state, and are difficult to reset. Relies on a single test per-file to reset state. */
|
|
interface DirtyFixtures {
|
|
basicSerialisableGraph: SerialisableGraph
|
|
}
|
|
|
|
export const test = baseTest.extend<LitegraphFixtures>({
|
|
minimalGraph: async ({ }, use) => {
|
|
// Before each test function
|
|
const serialisable = structuredClone(minimalSerialisableGraph)
|
|
const lGraph = new LGraph(serialisable)
|
|
|
|
// use the fixture value
|
|
await use(lGraph)
|
|
},
|
|
minimalSerialisableGraph: structuredClone(minimalSerialisableGraph),
|
|
oldSchemaGraph: structuredClone(oldSchemaGraph),
|
|
})
|
|
|
|
/** Test that use {@link DirtyFixtures}. One test per file. */
|
|
export const dirtyTest = test.extend<DirtyFixtures>({
|
|
basicSerialisableGraph: async ({}, use) => {
|
|
if (!basicSerialisableGraph.nodes) throw new Error("Invalid test object")
|
|
|
|
// Register node types
|
|
for (const node of basicSerialisableGraph.nodes) {
|
|
LiteGraph.registerNodeType(node.type!, LiteGraph.LGraphNode)
|
|
}
|
|
|
|
await use(structuredClone(basicSerialisableGraph))
|
|
},
|
|
})
|