1- import { deprecate } from '../utils'
1+ import { deprecate , checkHtmlElement , HtmlElementTypeError } from '../utils'
2+ import document from './helpers/document'
23
34test ( 'deprecate' , ( ) => {
45 const spy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } )
@@ -14,3 +15,46 @@ test('deprecate', () => {
1415
1516 spy . mockRestore ( )
1617} )
18+
19+ describe ( 'checkHtmlElement' , ( ) => {
20+ it ( 'does not throw an error for correct html element' , ( ) => {
21+ expect ( ( ) => {
22+ const element = document . createElement ( 'p' )
23+ checkHtmlElement ( element , ( ) => { } , { } )
24+ } ) . not . toThrow ( )
25+ } )
26+
27+ it ( 'does not throw an error for correct svg element' , ( ) => {
28+ expect ( ( ) => {
29+ const element = document . createElementNS (
30+ 'http://www.w3.org/2000/svg' ,
31+ 'rect' ,
32+ )
33+ checkHtmlElement ( element , ( ) => { } , { } )
34+ } ) . not . toThrow ( )
35+ } )
36+
37+ it ( 'does not throw for body' , ( ) => {
38+ expect ( ( ) => {
39+ checkHtmlElement ( document . body , ( ) => { } , { } )
40+ } ) . not . toThrow ( )
41+ } )
42+
43+ it ( 'throws for undefined' , ( ) => {
44+ expect ( ( ) => {
45+ checkHtmlElement ( undefined , ( ) => { } , { } )
46+ } ) . toThrow ( HtmlElementTypeError )
47+ } )
48+
49+ it ( 'throws for document' , ( ) => {
50+ expect ( ( ) => {
51+ checkHtmlElement ( document , ( ) => { } , { } )
52+ } ) . toThrow ( HtmlElementTypeError )
53+ } )
54+
55+ it ( 'throws for function' , ( ) => {
56+ expect ( ( ) => {
57+ checkHtmlElement ( ( ) => { } , ( ) => { } , { } )
58+ } ) . toThrow ( HtmlElementTypeError )
59+ } )
60+ } )
0 commit comments