Files
ComfyUI_frontend/test/LGraph.test.ts
filtered 6ee95f1201 TypeScript conversion groundwork (#163)
* ContextMenu ES6 class conversion

* Fix compat with extensions

* CurveEditor ES6 class conversion

* Split most of the LiteGraph global out to a class

* Move remainder of LiteGraph global to class file

* Remove IIFE wrapper

* Fix jest tests throwing due to type narrowing
2024-09-27 08:20:30 +09:00

28 lines
861 B
TypeScript

import {
LGraph,
LiteGraph,
} from "../dist/litegraph.es.js";
describe("LegacyLGraph Compatibility Layer", () => {
test("LGraph can be instantiated", () => {
const graph = new LGraph({extra: "TestGraph"});
expect(graph).toBeInstanceOf(LGraph);
expect(graph.extra).toBe("TestGraph");
});
test("LGraph 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";
};
// @ts-expect-error Should always be an error.
expect(graph.newMethod()).toBe("New method added via prototype");
});
test("LegacyLGraph is correctly assigned to LiteGraph", () => {
// @ts-expect-error Fixed later in the TS conversion process.
expect(LiteGraph.LGraph).toBe(LGraph);
});
});