Skip to content

Commit 3cfc5ed

Browse files
test: integer parent id 0 works as expected
1 parent 7540bb2 commit 3cfc5ed

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/arrayToTree.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ describe("arrayToTree", () => {
5454
]);
5555
});
5656

57+
it("should work with integer parentId 0", () => {
58+
expect(
59+
arrayToTree([
60+
{ id: 0, parentId: null, custom: "abc" },
61+
{ id: 31, parentId: 0, custom: "12" },
62+
])
63+
).to.deep.equal([
64+
{
65+
data: { id: 0, parentId: null, custom: "abc" },
66+
children: [
67+
{ data: { id: 31, parentId: 0, custom: "12" }, children: [] },
68+
],
69+
},
70+
]);
71+
});
72+
5773
it("should work with nested objects and custom keys", () => {
5874
expect(
5975
arrayToTree(

0 commit comments

Comments
 (0)