mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-02 20:22:08 +00:00
Add 'src/lib/litegraph/' from commit '1b58bf4966e9cdaa04bfaa40f5650b6c6680ab97'
git-subtree-dir: src/lib/litegraph git-subtree-mainline:1eadf80fecgit-subtree-split:1b58bf4966
This commit is contained in:
42
src/lib/litegraph/test/litegraph.test.ts
Normal file
42
src/lib/litegraph/test/litegraph.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { beforeEach, describe, expect, vi } from "vitest"
|
||||
|
||||
import { clamp, LGraphCanvas, LiteGraph } from "@/litegraph"
|
||||
import { LiteGraphGlobal } from "@/LiteGraphGlobal"
|
||||
|
||||
import { test } from "./testExtensions"
|
||||
|
||||
describe("Litegraph module", () => {
|
||||
test("contains a global export", ({ expect }) => {
|
||||
expect(LiteGraph).toBeInstanceOf(LiteGraphGlobal)
|
||||
expect(LiteGraph.LGraphCanvas).toBe(LGraphCanvas)
|
||||
})
|
||||
|
||||
test("has the same structure", ({ expect }) => {
|
||||
const lgGlobal = new LiteGraphGlobal()
|
||||
expect(lgGlobal).toMatchSnapshot("minLGraph")
|
||||
})
|
||||
|
||||
test("clamps values", () => {
|
||||
expect(clamp(-1.124, 13, 24)).toStrictEqual(13)
|
||||
expect(clamp(Infinity, 18, 29)).toStrictEqual(29)
|
||||
})
|
||||
})
|
||||
|
||||
describe("Import order dependency", () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules()
|
||||
})
|
||||
|
||||
test("Imports without error when entry point is imported first", async ({ expect }) => {
|
||||
async function importNormally() {
|
||||
const entryPointImport = await import("@/litegraph")
|
||||
const directImport = await import("@/LGraph")
|
||||
|
||||
// Sanity check that imports were cleared.
|
||||
expect(Object.is(LiteGraph, entryPointImport.LiteGraph)).toBe(false)
|
||||
expect(Object.is(LiteGraph.LGraph, directImport.LGraph)).toBe(false)
|
||||
}
|
||||
|
||||
await expect(importNormally()).resolves.toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user