From 94f1ca4279beeec82c642994ff58189eff56649d Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:00:02 +1100 Subject: [PATCH] Remove future test (#249) --- test/LGraph.test.ts | 59 +++++++++++++++++++++++++++-------------- test/LGraphNode.test.ts | 15 ++++++----- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/test/LGraph.test.ts b/test/LGraph.test.ts index bda242b4f..8a1680665 100644 --- a/test/LGraph.test.ts +++ b/test/LGraph.test.ts @@ -1,26 +1,45 @@ -import { - LGraph, - LiteGraph, -} from "../dist/litegraph.es.js"; +import { LGraph, LGraphGroup, LGraphNode, LiteGraph } from "../src/litegraph" +import { LiteGraphGlobal } from "../src/LiteGraphGlobal" -describe("LegacyLGraph Compatibility Layer", () => { - test("LGraph can be instantiated", () => { - const graph = new LGraph({extra: "TestGraph"}); - expect(graph).toBeInstanceOf(LGraph); - expect(graph.extra).toBe("TestGraph"); - }); +function makeGraph() { + const LiteGraph = new LiteGraphGlobal() + LiteGraph.registerNodeType("TestNode", LGraphNode) + LiteGraph.registerNodeType("OtherNode", LGraphNode) + LiteGraph.registerNodeType("", LGraphNode) + return new LGraph() +} - test("LGraph can be extended via prototype", () => { - const graph = new LGraph(); +describe("LGraph", () => { + it("can be instantiated", () => { + // @ts-ignore TODO: Remove once relative imports fix goes in. + const graph = new LGraph({ extra: "TestGraph" }) + expect(graph).toBeInstanceOf(LGraph) + expect(graph.extra).toBe("TestGraph") + }) +}) + +describe("Legacy LGraph Compatibility Layer", () => { + it("can be extended via prototype", () => { + const graph = new LGraph() // @ts-expect-error Should always be an error. LGraph.prototype.newMethod = function () { - return "New method added via prototype"; - }; + return "New method added via prototype" + } // @ts-expect-error Should always be an error. - expect(graph.newMethod()).toBe("New method added via prototype"); - }); + expect(graph.newMethod()).toBe("New method added via prototype") + }) - test("LegacyLGraph is correctly assigned to LiteGraph", () => { - expect(LiteGraph.LGraph).toBe(LGraph); - }); -}); + it("is correctly assigned to LiteGraph", () => { + expect(LiteGraph.LGraph).toBe(LGraph) + }) +}) + +describe("LGraph Serialisation", () => { + it("should serialise", () => { + const graph = new LGraph() + graph.add(new LGraphNode("Test Node")) + graph.add(new LGraphGroup("Test Group")) + expect(graph.nodes.length).toBe(1) + expect(graph.groups.length).toBe(1) + }) +}) diff --git a/test/LGraphNode.test.ts b/test/LGraphNode.test.ts index 1543edf86..a846dc637 100644 --- a/test/LGraphNode.test.ts +++ b/test/LGraphNode.test.ts @@ -1,12 +1,13 @@ import { LGraphNode, -} from "../dist/litegraph.es.js"; +} from "../src/litegraph" describe("LGraphNode", () => { it("should serialize position correctly", () => { - const node = new LGraphNode("TestNode"); - node.pos = [10, 10]; - expect(node.pos).toEqual(new Float32Array([10, 10])); - expect(node.serialize().pos).toEqual(new Float32Array([10, 10])); - }); -}); \ No newline at end of file + const node = new LGraphNode("TestNode") + node.pos = [10, 10] + expect(node.pos).toEqual(new Float32Array([10, 10])) + expect(node.serialize().pos).toEqual(new Float32Array([10, 10])) + }) + +}) \ No newline at end of file