@@ -5,17 +5,35 @@ test('.toBeEmptyDOMElement', () => {
5
5
<span data-testid="not-empty">
6
6
<span data-testid="empty"></span>
7
7
<svg data-testid="svg-empty"></svg>
8
- </span>` )
8
+ </span>
9
+ <span data-testid="with-comment"><!-- This Comment --></span>
10
+ <span data-testid="with-multiple-comments"><!-- Comment1 --><!-- Comment2 --></span>
11
+ <span data-testid="with-element"><span></span></span>
12
+ <span data-testid="with-element-and-comment"><!--Comment--><span></span></span>
13
+ <span data-testid="with-whitespace"> </span>
14
+ <span data-testid="with-text">Text</span>` )
9
15
10
16
const empty = queryByTestId ( 'empty' )
11
17
const notEmpty = queryByTestId ( 'not-empty' )
12
18
const svgEmpty = queryByTestId ( 'svg-empty' )
19
+ const withComment = queryByTestId ( 'with-comment' )
20
+ const withMultipleComments = queryByTestId ( 'with-multiple-comments' )
21
+ const withElement = queryByTestId ( 'with-element' )
22
+ const withElementAndComment = queryByTestId ( 'with-element-and-comment' )
23
+ const withWhitespace = queryByTestId ( 'with-whitespace' )
24
+ const withText = queryByTestId ( 'with-whitespace' )
13
25
const nonExistantElement = queryByTestId ( 'not-exists' )
14
26
const fakeElement = { thisIsNot : 'an html element' }
15
27
16
28
expect ( empty ) . toBeEmptyDOMElement ( )
17
29
expect ( svgEmpty ) . toBeEmptyDOMElement ( )
18
30
expect ( notEmpty ) . not . toBeEmptyDOMElement ( )
31
+ expect ( withComment ) . toBeEmptyDOMElement ( )
32
+ expect ( withMultipleComments ) . toBeEmptyDOMElement ( )
33
+ expect ( withElement ) . not . toBeEmptyDOMElement ( )
34
+ expect ( withElementAndComment ) . not . toBeEmptyDOMElement ( )
35
+ expect ( withWhitespace ) . not . toBeEmptyDOMElement ( )
36
+ expect ( withText ) . not . toBeEmptyDOMElement ( )
19
37
20
38
// negative test cases wrapped in throwError assertions for coverage.
21
39
expect ( ( ) => expect ( empty ) . not . toBeEmptyDOMElement ( ) ) . toThrowError ( )
@@ -24,6 +42,18 @@ test('.toBeEmptyDOMElement', () => {
24
42
25
43
expect ( ( ) => expect ( notEmpty ) . toBeEmptyDOMElement ( ) ) . toThrowError ( )
26
44
45
+ expect ( ( ) => expect ( withComment ) . not . toBeEmptyDOMElement ( ) ) . toThrowError ( )
46
+
47
+ expect ( ( ) => expect ( withMultipleComments ) . not . toBeEmptyDOMElement ( ) ) . toThrowError ( )
48
+
49
+ expect ( ( ) => expect ( withElement ) . toBeEmptyDOMElement ( ) ) . toThrowError ( )
50
+
51
+ expect ( ( ) => expect ( withElementAndComment ) . toBeEmptyDOMElement ( ) ) . toThrowError ( )
52
+
53
+ expect ( ( ) => expect ( withWhitespace ) . toBeEmptyDOMElement ( ) ) . toThrowError ( )
54
+
55
+ expect ( ( ) => expect ( withText ) . toBeEmptyDOMElement ( ) ) . toThrowError ( )
56
+
27
57
expect ( ( ) => expect ( fakeElement ) . toBeEmptyDOMElement ( ) ) . toThrowError ( )
28
58
29
59
expect ( ( ) => {
0 commit comments