diff --git a/bun.lock b/bun.lock index 969f4b3f06..8491d2cd27 100644 --- a/bun.lock +++ b/bun.lock @@ -1046,6 +1046,7 @@ "@types/d3-scale": "^4.0.9", "@types/d3-shape": "^3.2.0", "@types/node": "catalog:tooling", + "happy-dom": "^21.0.4", "typescript": "catalog:tooling", "vite": "catalog:", "vitest": "catalog:", diff --git a/packages/views/package.json b/packages/views/package.json index 2e1bb38e53..8db6427d65 100644 --- a/packages/views/package.json +++ b/packages/views/package.json @@ -38,6 +38,7 @@ "@types/d3-scale": "^4.0.9", "@types/d3-shape": "^3.2.0", "@types/node": "catalog:tooling", + "happy-dom": "^21.0.4", "typescript": "catalog:tooling", "vite": "catalog:", "vitest": "catalog:" diff --git a/packages/views/src/lib/findable.test.ts b/packages/views/src/lib/findable.test.ts new file mode 100644 index 0000000000..9b5e81506e --- /dev/null +++ b/packages/views/src/lib/findable.test.ts @@ -0,0 +1,77 @@ +// @vitest-environment happy-dom +import { Virtualizer } from "@tanstack/virtual-core" +import { describe, expect, test } from "vitest" +import { bindFindable, type FindableMatch } from "./findable" +import { DOM_OPTIONS, type Instance } from "./virtualizer" + +const ROW_HEIGHT = 30 + +/** A scroller with both stand-in layers, as `findableLayers` renders them, over a measured virtualizer. */ +const setUp = (count: number, scrollMargin = 0) => { + const scroller = document.createElement("div") + scroller.innerHTML = ` +