mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-29 08:33:31 +00:00
test(app): cover Solid virtualizer cache updates
This commit is contained in:
parent
6ad0e88657
commit
d928967f4d
2 changed files with 29 additions and 1 deletions
|
|
@ -17,8 +17,9 @@
|
|||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"serve": "vite preview",
|
||||
"test": "bun run test:unit",
|
||||
"test": "bun run test:unit && bun run test:virtualizer",
|
||||
"test:unit": "bun test --only-failures --preload ./happydom.ts ./src",
|
||||
"test:virtualizer": "bun test --conditions=browser --preload ./happydom.ts ./test-browser/solid-virtual.test.ts",
|
||||
"test:unit:watch": "bun test --watch --preload ./happydom.ts ./src",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:local": "playwright test",
|
||||
|
|
|
|||
27
packages/app/test-browser/solid-virtual.test.ts
Normal file
27
packages/app/test-browser/solid-virtual.test.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { createVirtualizer } from "@tanstack/solid-virtual"
|
||||
import { createRoot, createSignal } from "solid-js"
|
||||
|
||||
test("reactive count updates preserve measured row sizes", () => {
|
||||
createRoot((dispose) => {
|
||||
const [count, setCount] = createSignal(2)
|
||||
const virtualizer = createVirtualizer<HTMLDivElement, HTMLDivElement>({
|
||||
get count() {
|
||||
return count()
|
||||
},
|
||||
getScrollElement: () => null,
|
||||
estimateSize: () => 60,
|
||||
initialRect: { width: 800, height: 600 },
|
||||
})
|
||||
|
||||
expect(virtualizer.getTotalSize()).toBe(120)
|
||||
virtualizer.resizeItem(0, 100)
|
||||
expect(virtualizer.getTotalSize()).toBe(160)
|
||||
|
||||
setCount(3)
|
||||
|
||||
expect(virtualizer.itemSizeCache.get(0)).toBe(100)
|
||||
expect(virtualizer.getTotalSize()).toBe(220)
|
||||
dispose()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue