Skip to content

Commit

Permalink
test: integer parent id 0 works as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
philipstanislaus committed Feb 17, 2022
1 parent 7540bb2 commit 3cfc5ed
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/arrayToTree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ describe("arrayToTree", () => {
]);
});

it("should work with integer parentId 0", () => {
expect(
arrayToTree([
{ id: 0, parentId: null, custom: "abc" },
{ id: 31, parentId: 0, custom: "12" },
])
).to.deep.equal([
{
data: { id: 0, parentId: null, custom: "abc" },
children: [
{ data: { id: 31, parentId: 0, custom: "12" }, children: [] },
],
},
]);
});

it("should work with nested objects and custom keys", () => {
expect(
arrayToTree(
Expand Down

0 comments on commit 3cfc5ed

Please sign in to comment.