Download packages/app/src/components/pierre-tree.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 689 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/pierre-tree.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/components/pierre-tree.test.ts
-
curl -L -o pierre-tree.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/pierre-tree.test.ts
689 Bytes
| import { expect, test } from "bun:test" | |
| import { FileTree, type FileTreeDirectoryHandle } from "@pierre/trees" | |
| test("reports directory expansion changes", () => { | |
| const changes: Array<{ path: string; expanded: boolean }> = [] | |
| const tree = new FileTree({ | |
| paths: ["src/"], | |
| onExpansionChange: (change) => changes.push(change), | |
| }) | |
| const src = tree.getItem("src/") | |
| if (!src || !src.isDirectory()) throw new Error("Expected src to be a directory") | |
| const directory = src as FileTreeDirectoryHandle | |
| directory.expand() | |
| directory.collapse() | |
| expect(changes).toEqual([ | |
| { path: "src/", expanded: true }, | |
| { path: "src/", expanded: false }, | |
| ]) | |
| tree.cleanUp() | |
| }) | |