@@ -2,19 +2,37 @@ import {HtmlElementTypeError} from '../utils'
2
2
import document from './helpers/document'
3
3
4
4
test ( '.toBeInTheDocument' , ( ) => {
5
+ const window = document . defaultView
6
+
7
+ window . customElements . define (
8
+ 'custom-element' ,
9
+ class extends window . HTMLElement {
10
+ constructor ( ) {
11
+ super ( )
12
+ this . attachShadow ( { mode : 'open' } ) . innerHTML =
13
+ '<div data-testid="custom-element-child"></div>'
14
+ }
15
+ } ,
16
+ )
17
+
5
18
document . body . innerHTML = `
6
19
<span data-testid="html-element"><span>Html Element</span></span>
7
- <svg data-testid="svg-element"></svg>`
20
+ <svg data-testid="svg-element"></svg>
21
+ <custom-element data-testid="custom-element"></custom-element>`
8
22
9
23
const htmlElement = document . querySelector ( '[data-testid="html-element"]' )
10
24
const svgElement = document . querySelector ( '[data-testid="svg-element"]' )
25
+ const customElementChild = document
26
+ . querySelector ( '[data-testid="custom-element"]' )
27
+ . shadowRoot . querySelector ( '[data-testid="custom-element-child"]' )
11
28
const detachedElement = document . createElement ( 'div' )
12
29
const fakeElement = { thisIsNot : 'an html element' }
13
30
const undefinedElement = undefined
14
31
const nullElement = null
15
32
16
33
expect ( htmlElement ) . toBeInTheDocument ( )
17
34
expect ( svgElement ) . toBeInTheDocument ( )
35
+ expect ( customElementChild ) . toBeInTheDocument ( )
18
36
expect ( detachedElement ) . not . toBeInTheDocument ( )
19
37
expect ( nullElement ) . not . toBeInTheDocument ( )
20
38
0 commit comments