Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,44 @@ test("simple children", function (t) {
);
});

test("bigint children", function (t) {
t.plan(4);

const { container } = render(
<Assert
assert={(result) => {
t.equal(result.length, 4, "array length");

t.equal(isElement(result[0]) && result[0].key, ".0", "0th element key");
t.equal(result[1], 10n, "1st bigint child");
t.equal(result[3], BigInt(20), "3rd BigInt() child");
}}
>
<span>one</span>
{10n}
<span>two</span>
{BigInt(20)}
</Assert>
);
});

test("bigint in nested fragments", function (t) {
t.plan(2);

const { container } = render(
<Assert
assert={(result) => {
t.equal(result.length, 1, "array length");
t.equal(result[0], 100n, "nested bigint preserved");
}}
>
<>
<>{100n}</>
</>
</Assert>
);
});

test("nested arrays and fragments with mixed content", function (t) {
t.plan(2);

Expand Down
6 changes: 5 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export default function flattenChildren(
key: keys.concat(String(node.key)).join("."),
})
);
} else if (typeof node === "string" || typeof node === "number") {
} else if (
typeof node === "string" ||
typeof node === "number" ||
typeof node === "bigint"
) {
acc.push(node);
}
}
Expand Down
Loading