File tree Expand file tree Collapse file tree
packages/query-devtools/src/__tests__/contexts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -261,4 +261,49 @@ describe('PiPContext', () => {
261261 )
262262 } )
263263 } )
264+
265+ describe ( '"closePipWindow"' , ( ) => {
266+ it ( 'should be a noop when no window is open' , ( ) => {
267+ const { fakeWindow } = stubPipWindow ( )
268+
269+ renderAndAct ( ( pip ) => {
270+ pip ( ) . closePipWindow ( )
271+ } )
272+
273+ expect ( fakeWindow . close ) . not . toHaveBeenCalled ( )
274+ } )
275+
276+ it ( 'should call "close" on the opened window and reset the "pipWindow" signal' , ( ) => {
277+ const { fakeWindow } = stubPipWindow ( )
278+ const observed : Array < Window | null > = [ ]
279+
280+ renderAndAct (
281+ ( pip ) => {
282+ pip ( ) . requestPipWindow ( 640 , 480 )
283+ observed . push ( pip ( ) . pipWindow )
284+ pip ( ) . closePipWindow ( )
285+ observed . push ( pip ( ) . pipWindow )
286+ } ,
287+ { disabled : true } ,
288+ )
289+
290+ expect ( fakeWindow . close ) . toHaveBeenCalledTimes ( 1 )
291+ expect ( observed ) . toEqual ( [ fakeWindow , null ] )
292+ } )
293+
294+ it ( 'should call "close" only once when "closePipWindow" runs twice in a row' , ( ) => {
295+ const { fakeWindow } = stubPipWindow ( )
296+
297+ renderAndAct (
298+ ( pip ) => {
299+ pip ( ) . requestPipWindow ( 640 , 480 )
300+ pip ( ) . closePipWindow ( )
301+ pip ( ) . closePipWindow ( )
302+ } ,
303+ { disabled : true } ,
304+ )
305+
306+ expect ( fakeWindow . close ) . toHaveBeenCalledTimes ( 1 )
307+ } )
308+ } )
264309} )
You can’t perform that action at this time.
0 commit comments