@@ -18,21 +18,18 @@ describe('.toContainHTML', () => {
1818 const nonExistantElement = queryByTestId ( 'not-exists' )
1919 const fakeElement = { thisIsNot : 'an html element' }
2020 const stringChildElement = '<span data-testid="child"></span>'
21- const incorrectStringHtml = '<span data-testid="child"></div >'
21+ const stringChildElementSelfClosing = '<span data-testid="child" / >'
2222 const nonExistantString = '<span> Does not exists </span>'
2323 const svgElement = queryByTestId ( 'svg-element' )
2424
2525 expect ( grandparent ) . toContainHTML ( stringChildElement )
2626 expect ( parent ) . toContainHTML ( stringChildElement )
2727 expect ( child ) . toContainHTML ( stringChildElement )
28+ expect ( child ) . toContainHTML ( stringChildElementSelfClosing )
2829 expect ( grandparent ) . not . toContainHTML ( nonExistantString )
2930 expect ( parent ) . not . toContainHTML ( nonExistantString )
3031 expect ( child ) . not . toContainHTML ( nonExistantString )
3132 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 )
3633
3734 // negative test cases wrapped in throwError assertions for coverage.
3835 expect ( ( ) =>
@@ -59,6 +56,9 @@ describe('.toContainHTML', () => {
5956 expect ( ( ) =>
6057 expect ( child ) . not . toContainHTML ( stringChildElement ) ,
6158 ) . toThrowError ( )
59+ expect ( ( ) =>
60+ expect ( child ) . not . toContainHTML ( stringChildElementSelfClosing ) ,
61+ ) . toThrowError ( )
6262 expect ( ( ) => expect ( child ) . toContainHTML ( nonExistantString ) ) . toThrowError ( )
6363 expect ( ( ) => expect ( parent ) . toContainHTML ( nonExistantString ) ) . toThrowError ( )
6464 expect ( ( ) =>
@@ -71,18 +71,6 @@ describe('.toContainHTML', () => {
7171 expect ( ( ) =>
7272 expect ( grandparent ) . toContainHTML ( nonExistantElement ) ,
7373 ) . toThrowError ( )
74- expect ( ( ) =>
75- expect ( nonExistantElement ) . toContainHTML ( incorrectStringHtml ) ,
76- ) . toThrowError ( )
77- expect ( ( ) =>
78- expect ( grandparent ) . toContainHTML ( incorrectStringHtml ) ,
79- ) . toThrowError ( )
80- expect ( ( ) =>
81- expect ( child ) . toContainHTML ( incorrectStringHtml ) ,
82- ) . toThrowError ( )
83- expect ( ( ) =>
84- expect ( parent ) . toContainHTML ( incorrectStringHtml ) ,
85- ) . toThrowError ( )
8674 } )
8775
8876 test ( 'throws with an expected text' , ( ) => {
0 commit comments