Skip to content

Commit 1f78272

Browse files
Add isEmpty doc.
1 parent 496edc5 commit 1f78272

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/native/src/lib/ToBeEmptyElementAssertion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ToBeEmptyElementAssertion extends Assertion<ReactTestInstance> {
4040
});
4141

4242
return this.execute({
43-
assertWhen: isEmpty(this.actual),
43+
assertWhen: isEmpty(this.actual.children),
4444
error,
4545
invertedError,
4646
});

packages/native/src/lib/helpers/helpers.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { ReactTestInstance } from "react-test-renderer";
2-
3-
export function isEmpty(element: ReactTestInstance): boolean {
4-
const children = element?.children;
5-
6-
if (!children) {
1+
/**
2+
* Checks if a value is empty.
3+
*
4+
* @param value - The value to check.
5+
* @returns `true` if the value is empty, `false` otherwise.
6+
*/
7+
export function isEmpty(value: unknown): boolean {
8+
if (!value) {
79
return true;
810
}
911

10-
if (Array.isArray(children)) {
11-
return children.length === 0;
12+
if (Array.isArray(value)) {
13+
return value.length === 0;
1214
}
1315

1416
return false;

0 commit comments

Comments
 (0)