-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary compatibility layer
- Loading branch information
Showing
2 changed files
with
9 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,24 @@ | ||
import { | ||
LGraphES6 as LGraph, | ||
LGraph as LegacyLGraph, | ||
LGraph, | ||
LiteGraph, | ||
} from "../dist/litegraph.es.js"; | ||
|
||
describe("LegacyLGraph Compatibility Layer", () => { | ||
test("LegacyLGraph can be instantiated", () => { | ||
const graph = new LegacyLGraph({extra: "TestGraph"}); | ||
test("LGraph can be instantiated", () => { | ||
const graph = new LGraph({extra: "TestGraph"}); | ||
expect(graph).toBeInstanceOf(LGraph); | ||
expect(graph).toBeInstanceOf(LegacyLGraph); | ||
expect(graph.extra).toBe("TestGraph"); | ||
}); | ||
|
||
test("LegacyLGraph can be extended via prototype", () => { | ||
LegacyLGraph.prototype.newMethod = function () { | ||
test("LGraph can be extended via prototype", () => { | ||
const graph = new LGraph(); | ||
LGraph.prototype.newMethod = function () { | ||
return "New method added via prototype"; | ||
}; | ||
|
||
const graph = new LegacyLGraph(); | ||
expect(graph.newMethod()).toBe("New method added via prototype"); | ||
}); | ||
|
||
test("Extensions to LegacyLGraph affect LGraph instances", () => { | ||
LegacyLGraph.prototype.anotherMethod = function () { | ||
return "Another method"; | ||
}; | ||
|
||
const legacyGraph = new LegacyLGraph(); | ||
const normalGraph = new LGraph(); | ||
|
||
expect(legacyGraph.anotherMethod()).toBe("Another method"); | ||
expect(normalGraph.anotherMethod()).toBe("Another method"); | ||
}); | ||
|
||
test("LegacyLGraph is correctly assigned to LiteGraph", () => { | ||
expect(LiteGraph.LGraph).toBe(LegacyLGraph); | ||
expect(LiteGraph.LGraph).toBe(LGraph); | ||
}); | ||
}); |