Revert branch to cb6e80a645 (#257)

This commit is contained in:
Chenlei Hu
2024-11-03 09:12:47 -05:00
committed by GitHub
parent 9b0f572ca1
commit 7c0240857c
27 changed files with 14195 additions and 13800 deletions

View File

@@ -1,44 +1,44 @@
import { LGraph, LGraphGroup, LGraphNode, LiteGraph } from '../src/litegraph'
import { LiteGraphGlobal } from '../src/LiteGraphGlobal'
import { LGraph, LGraphGroup, LGraphNode, LiteGraph } from "../src/litegraph"
import { LiteGraphGlobal } from "../src/LiteGraphGlobal"
function makeGraph() {
const LiteGraph = new LiteGraphGlobal()
LiteGraph.registerNodeType('TestNode', LGraphNode)
LiteGraph.registerNodeType('OtherNode', LGraphNode)
LiteGraph.registerNodeType('', LGraphNode)
LiteGraph.registerNodeType("TestNode", LGraphNode)
LiteGraph.registerNodeType("OtherNode", LGraphNode)
LiteGraph.registerNodeType("", LGraphNode)
return new LGraph()
}
describe('LGraph', () => {
it('can be instantiated', () => {
describe("LGraph", () => {
it("can be instantiated", () => {
// @ts-ignore TODO: Remove once relative imports fix goes in.
const graph = new LGraph({ extra: 'TestGraph' })
const graph = new LGraph({ extra: "TestGraph" })
expect(graph).toBeInstanceOf(LGraph)
expect(graph.extra).toBe('TestGraph')
expect(graph.extra).toBe("TestGraph")
})
})
describe('Legacy LGraph Compatibility Layer', () => {
it('can be extended via prototype', () => {
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")
})
it('is correctly assigned to LiteGraph', () => {
it("is correctly assigned to LiteGraph", () => {
expect(LiteGraph.LGraph).toBe(LGraph)
})
})
describe('LGraph Serialisation', () => {
it('should serialise', () => {
describe("LGraph Serialisation", () => {
it("should serialise", () => {
const graph = new LGraph()
graph.add(new LGraphNode('Test Node'))
graph.add(new LGraphGroup('Test Group'))
graph.add(new LGraphNode("Test Node"))
graph.add(new LGraphGroup("Test Group"))
expect(graph.nodes.length).toBe(1)
expect(graph.groups.length).toBe(1)
})