File tree Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { Assertion , AssertionError } from "@assertive-ts/core" ;
2
2
import { ReactTestInstance } from "react-test-renderer" ;
3
3
4
+ import { isEmpty } from "./helpers/helpers" ;
5
+
6
+ /**
7
+ * Assertion for checking if a React element is empty.
8
+ */
4
9
export class ToBeEmptyElementAssertion extends Assertion < ReactTestInstance > {
5
10
public constructor ( actual : ReactTestInstance ) {
6
11
super ( actual ) ;
@@ -35,23 +40,9 @@ export class ToBeEmptyElementAssertion extends Assertion<ReactTestInstance> {
35
40
} ) ;
36
41
37
42
return this . execute ( {
38
- assertWhen : this . isEmpty ( this . actual ) ,
43
+ assertWhen : isEmpty ( this . actual ) ,
39
44
error,
40
45
invertedError,
41
46
} ) ;
42
47
}
43
-
44
- private isEmpty ( element : ReactTestInstance ) : boolean {
45
- const children = element ?. children ;
46
-
47
- if ( ! children ) {
48
- return true ;
49
- }
50
-
51
- if ( Array . isArray ( children ) ) {
52
- return children . length === 0 ;
53
- }
54
-
55
- return false ;
56
- }
57
48
}
Original file line number Diff line number Diff line change
1
+ import { ReactTestInstance } from "react-test-renderer" ;
2
+
3
+ export function isEmpty ( element : ReactTestInstance ) : boolean {
4
+ const children = element ?. children ;
5
+
6
+ if ( ! children ) {
7
+ return true ;
8
+ }
9
+
10
+ if ( Array . isArray ( children ) ) {
11
+ return children . length === 0 ;
12
+ }
13
+
14
+ return false ;
15
+ }
You can’t perform that action at this time.
0 commit comments