@@ -259,6 +259,37 @@ describe("PanelResizeHandle", () => {
259259 } ) ;
260260 } ) ;
261261
262+
263+ describe ( "event handlers when rendered in a separate document" , ( ) => {
264+ let separateWindowDocument : Document ;
265+ beforeEach ( ( ) => {
266+ // @ts -expect-error
267+ global . IS_REACT_ACT_ENVIRONMENT = true ;
268+
269+ separateWindowDocument = document . implementation . createHTMLDocument ( ) ;
270+ container = separateWindowDocument . createElement ( "div" ) ;
271+ separateWindowDocument . body . appendChild ( container ) ;
272+ jest . spyOn ( separateWindowDocument . body , "addEventListener" ) ;
273+ jest . spyOn ( document . body , "addEventListener" ) ;
274+ expectedWarnings = [ ] ;
275+ root = createRoot ( container ) ;
276+ } ) ;
277+
278+ it ( "should add the pointerup event to the separate document NOT the main document" , ( ) => {
279+ const { leftElement } = setupMockedGroup ( ) ;
280+
281+ act ( ( ) => {
282+ dispatchPointerEvent ( "pointerdown" , leftElement ) ;
283+ dispatchPointerEvent ( "pointerup" , leftElement ) ;
284+ } ) ;
285+
286+ expect ( separateWindowDocument . body . addEventListener ) . toHaveBeenCalledWith ( "pointerup" , expect . anything ( ) , expect . anything ( ) ) ;
287+ expect ( document . body . addEventListener ) . not . toHaveBeenCalled ( ) ;
288+
289+ } ) ;
290+ } ) ;
291+
292+
262293 describe ( "data attributes" , ( ) => {
263294 test ( "should initialize with the correct props based attributes" , ( ) => {
264295 const { leftElement, rightElement } = setupMockedGroup ( ) ;
0 commit comments