File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,24 @@ describe('useIframeBehavior', () => {
122
122
expect ( setWindowTopOffset ) . toHaveBeenCalledWith ( window . scrollY ) ;
123
123
} ) ;
124
124
125
+ it ( 'handles xblockScroll message correctly' , ( ) => {
126
+ document . body . innerHTML = '<div id="window" top: 25px;"><div id="xblock-iframe" style="position: absolute; top: 50px;"></div></div>' ;
127
+ renderHook ( ( ) => useIframeBehavior ( { id, iframeUrl, iframeRef } ) ) ;
128
+
129
+ const message = {
130
+ type : iframeMessageTypes . xblockScroll ,
131
+ data : { offset : 100 } ,
132
+ } ;
133
+
134
+ act ( ( ) => {
135
+ window . dispatchEvent ( new MessageEvent ( 'message' , message ) ) ;
136
+ } ) ;
137
+
138
+ expect ( window . scrollY ) . toBe ( 100
139
+ + ( document . getElementById ( 'xblock-iframe' ) as HTMLElement ) . offsetTop
140
+ + ( document . getElementById ( 'xblock-iframe' ) ?. parentElement as HTMLElement ) . offsetTop ) ;
141
+ } ) ;
142
+
125
143
it ( 'handles offset message correctly' , ( ) => {
126
144
document . body . innerHTML = '<div id="unit-iframe" style="position: absolute; top: 50px;"></div>' ;
127
145
renderHook ( ( ) => useIframeBehavior ( { id, iframeUrl, iframeRef } ) ) ;
You can’t perform that action at this time.
0 commit comments