Skip to content

Commit acfb187

Browse files
kdquistanchalalopenchi
authored andcommitted
Add isEmpty doc.
1 parent 2cb97b4 commit acfb187

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ export function instanceToString(instance: ReactTestInstance | null): string {
1414
return `<${instance.type.toString()} ... />`;
1515
}
1616

17-
export function isEmpty(element: ReactTestInstance): boolean {
18-
const children = element?.children;
19-
20-
if (!children) {
17+
/**
18+
* Checks if a value is empty.
19+
*
20+
* @param value - The value to check.
21+
* @returns `true` if the value is empty, `false` otherwise.
22+
*/
23+
export function isEmpty(value: unknown): boolean {
24+
if (!value) {
2125
return true;
2226
}
2327

24-
if (Array.isArray(children)) {
25-
return children.length === 0;
28+
if (Array.isArray(value)) {
29+
return value.length === 0;
2630
}
2731

2832
return false;

0 commit comments

Comments
 (0)