@@ -18,21 +18,22 @@ describe('.toContainHTML', () => {
18
18
const nonExistantElement = queryByTestId ( 'not-exists' )
19
19
const fakeElement = { thisIsNot : 'an html element' }
20
20
const stringChildElement = '<span data-testid="child"></span>'
21
+ const stringChildElementSelfClosing = '<span data-testid="child" />'
21
22
const incorrectStringHtml = '<span data-testid="child"></div>'
22
23
const nonExistantString = '<span> Does not exists </span>'
23
24
const svgElement = queryByTestId ( 'svg-element' )
24
25
25
26
expect ( grandparent ) . toContainHTML ( stringChildElement )
26
27
expect ( parent ) . toContainHTML ( stringChildElement )
27
28
expect ( child ) . toContainHTML ( stringChildElement )
29
+ expect ( child ) . toContainHTML ( stringChildElementSelfClosing )
28
30
expect ( grandparent ) . not . toContainHTML ( nonExistantString )
29
31
expect ( parent ) . not . toContainHTML ( nonExistantString )
30
32
expect ( child ) . not . toContainHTML ( nonExistantString )
31
33
expect ( child ) . not . toContainHTML ( nonExistantString )
32
- expect ( grandparent ) . not . toContainHTML ( incorrectStringHtml )
33
- expect ( parent ) . not . toContainHTML ( incorrectStringHtml )
34
- expect ( child ) . not . toContainHTML ( incorrectStringHtml )
35
- expect ( child ) . not . toContainHTML ( incorrectStringHtml )
34
+ expect ( grandparent ) . toContainHTML ( incorrectStringHtml )
35
+ expect ( parent ) . toContainHTML ( incorrectStringHtml )
36
+ expect ( child ) . toContainHTML ( incorrectStringHtml )
36
37
37
38
// negative test cases wrapped in throwError assertions for coverage.
38
39
expect ( ( ) =>
@@ -59,6 +60,9 @@ describe('.toContainHTML', () => {
59
60
expect ( ( ) =>
60
61
expect ( child ) . not . toContainHTML ( stringChildElement ) ,
61
62
) . toThrowError ( )
63
+ expect ( ( ) =>
64
+ expect ( child ) . not . toContainHTML ( stringChildElementSelfClosing ) ,
65
+ ) . toThrowError ( )
62
66
expect ( ( ) => expect ( child ) . toContainHTML ( nonExistantString ) ) . toThrowError ( )
63
67
expect ( ( ) => expect ( parent ) . toContainHTML ( nonExistantString ) ) . toThrowError ( )
64
68
expect ( ( ) =>
@@ -72,16 +76,16 @@ describe('.toContainHTML', () => {
72
76
expect ( grandparent ) . toContainHTML ( nonExistantElement ) ,
73
77
) . toThrowError ( )
74
78
expect ( ( ) =>
75
- expect ( nonExistantElement ) . toContainHTML ( incorrectStringHtml ) ,
79
+ expect ( nonExistantElement ) . not . toContainHTML ( incorrectStringHtml ) ,
76
80
) . toThrowError ( )
77
81
expect ( ( ) =>
78
- expect ( grandparent ) . toContainHTML ( incorrectStringHtml ) ,
82
+ expect ( grandparent ) . not . toContainHTML ( incorrectStringHtml ) ,
79
83
) . toThrowError ( )
80
84
expect ( ( ) =>
81
- expect ( child ) . toContainHTML ( incorrectStringHtml ) ,
85
+ expect ( child ) . not . toContainHTML ( incorrectStringHtml ) ,
82
86
) . toThrowError ( )
83
87
expect ( ( ) =>
84
- expect ( parent ) . toContainHTML ( incorrectStringHtml ) ,
88
+ expect ( parent ) . not . toContainHTML ( incorrectStringHtml ) ,
85
89
) . toThrowError ( )
86
90
} )
87
91
0 commit comments