Add 'src/lib/litegraph/' from commit '1b58bf4966e9cdaa04bfaa40f5650b6c6680ab97'

git-subtree-dir: src/lib/litegraph
git-subtree-mainline: 1eadf80fec
git-subtree-split: 1b58bf4966
This commit is contained in:
Benjamin Lu
2025-08-03 14:55:05 -04:00
171 changed files with 48331 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import { describe, expect, it } from "vitest"
import { distributeSpace, type SpaceRequest } from "@/utils/spaceDistribution"
describe("distributeSpace", () => {
it("should distribute space according to minimum sizes when space is limited", () => {
const requests: SpaceRequest[] = [
{ minSize: 100 },
{ minSize: 100 },
{ minSize: 100 },
]
expect(distributeSpace(300, requests)).toEqual([100, 100, 100])
})
it("should distribute extra space equally when no maxSize", () => {
const requests: SpaceRequest[] = [{ minSize: 100 }, { minSize: 100 }]
expect(distributeSpace(400, requests)).toEqual([200, 200])
})
it("should respect maximum sizes", () => {
const requests: SpaceRequest[] = [
{ minSize: 100, maxSize: 150 },
{ minSize: 100 },
]
expect(distributeSpace(400, requests)).toEqual([150, 250])
})
it("should handle empty requests array", () => {
expect(distributeSpace(1000, [])).toEqual([])
})
it("should handle negative total space", () => {
const requests: SpaceRequest[] = [{ minSize: 100 }, { minSize: 100 }]
expect(distributeSpace(-100, requests)).toEqual([100, 100])
})
it("should handle total space smaller than minimum sizes", () => {
const requests: SpaceRequest[] = [{ minSize: 100 }, { minSize: 100 }]
expect(distributeSpace(100, requests)).toEqual([100, 100])
})
})