@@ -12,17 +12,67 @@ const el = { el: 'htmlElement' }
1212
1313it ( 'should observe' , ( ) => {
1414 const cb = jest . fn ( )
15- observe ( el , cb )
15+ const instance = observe ( el , cb )
16+
17+ expect ( instance ) . toMatchObject ( {
18+ observerId : '0' ,
19+ visible : false ,
20+ options : {
21+ threshold : 0 ,
22+ } ,
23+ } )
24+ } )
25+
26+ it ( 'should observe with options' , ( ) => {
27+ const cb = jest . fn ( )
28+ const instance = observe ( el , cb , { threshold : 0 } )
29+
30+ expect ( instance ) . toMatchObject ( {
31+ observerId : '0' ,
32+ visible : false ,
33+ options : {
34+ threshold : 0 ,
35+ } ,
36+ } )
1637} )
1738
1839it ( 'should observe with threshold' , ( ) => {
1940 const cb = jest . fn ( )
20- observe ( el , cb , 1 )
41+ const instance = observe ( el , cb , { threshold : 1 } )
42+
43+ expect ( instance ) . toMatchObject ( {
44+ observerId : '1' ,
45+ visible : false ,
46+ options : {
47+ threshold : 1 ,
48+ } ,
49+ } )
2150} )
2251
2352it ( 'should observe with Array threshold' , ( ) => {
2453 const cb = jest . fn ( )
25- observe ( el , cb , [ 0.3 , 0.6 ] )
54+ const instance = observe ( el , cb , { threshold : [ 0.3 , 0.6 ] } )
55+
56+ expect ( instance ) . toMatchObject ( {
57+ observerId : '0.3,0.6' ,
58+ visible : false ,
59+ options : {
60+ threshold : [ 0.3 , 0.6 ] ,
61+ } ,
62+ } )
63+ } )
64+
65+ it ( 'should observe with rootId' , ( ) => {
66+ const cb = jest . fn ( )
67+ const instance = observe ( el , cb , { threshold : 0 , root : { } } , 'window' )
68+
69+ expect ( instance ) . toMatchObject ( {
70+ observerId : 'window_0' ,
71+ visible : false ,
72+ options : {
73+ root : { } ,
74+ } ,
75+ } )
2676} )
2777
2878it ( 'should unobserve' , ( ) => {
0 commit comments