Skip to content

Commit 8501b1e

Browse files
committed
chore: fix tests
1 parent 08f10f1 commit 8501b1e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

packages/core/src/features/checkboxes/checkboxes.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe("core-feature/checkboxes", () => {
102102
it("should turn folder checked if all children are checked", async () => {
103103
const testTree = await tree
104104
.with({
105+
isItemFolder: (item: any) => item.getItemData().length < 4,
105106
propagateCheckedState: true,
106107
canCheckFolders: false,
107108
})

packages/core/src/features/tree/tree.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,22 @@ describe("core-feature/tree", () => {
327327
expect(tree.instance.getItemInstance("x1").isFolder()).toBe(true);
328328
});
329329

330-
it("returns correct isFolder for hidden items", () => {
330+
it("returns correct isFolder for hidden items", async () => {
331331
if (title.toLocaleLowerCase().includes("async")) {
332332
// async test tree defaults to "loading" item names
333333
return;
334334
}
335+
const testTree = await tree
336+
.with({
337+
isItemFolder: (item: any) => item.getItemData().length < 4,
338+
})
339+
.createTestCaseTree();
335340

336341
// Reference: https://github.com/lukasbach/headless-tree/issues/166
337-
expect(tree.instance.getItemInstance("x44").isFolder()).toBe(true);
338-
expect(tree.instance.getItemInstance("x444").isFolder()).toBe(false);
342+
expect(testTree.instance.getItemInstance("x44").isFolder()).toBe(true);
343+
expect(testTree.instance.getItemInstance("x444").isFolder()).toBe(
344+
false,
345+
);
339346
});
340347

341348
it("returns isFolder=true for root item", () => {

packages/core/src/test-utils/test-tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class TestTree<T = string> {
122122
},
123123
getItemName: (item) => item.getItemData(),
124124
indent: 20,
125-
isItemFolder: (item) => item.getItemData().length < 4,
125+
isItemFolder: (item) => item.getItemMeta().level < 2,
126126
initialState: {
127127
expandedItems: ["x1", "x11"],
128128
},

0 commit comments

Comments
 (0)