@@ -3,9 +3,34 @@ import React from 'react';
3
3
import Trigger , { UniqueProvider } from '../src' ;
4
4
import { awaitFakeTimer } from './util' ;
5
5
6
+ // Mock FloatBg to check if open props changed
7
+ global . openChangeLog = [ ] ;
8
+
9
+ jest . mock ( '../src/UniqueProvider/FloatBg' , ( ) => {
10
+ const OriginalFloatBg = jest . requireActual (
11
+ '../src/UniqueProvider/FloatBg' ,
12
+ ) . default ;
13
+ const OriginReact = jest . requireActual ( 'react' ) ;
14
+
15
+ return ( props : any ) => {
16
+ const { open } = props ;
17
+ const openRef = OriginReact . useRef ( open ) ;
18
+
19
+ OriginReact . useEffect ( ( ) => {
20
+ if ( openRef . current !== open ) {
21
+ global . openChangeLog . push ( { from : openRef . current , to : open } ) ;
22
+ openRef . current = open ;
23
+ }
24
+ } , [ open ] ) ;
25
+
26
+ return OriginReact . createElement ( OriginalFloatBg , props ) ;
27
+ } ;
28
+ } ) ;
29
+
6
30
describe ( 'Trigger.Unique' , ( ) => {
7
31
beforeEach ( ( ) => {
8
32
jest . useFakeTimers ( ) ;
33
+ global . openChangeLog = [ ] ;
9
34
} ) ;
10
35
11
36
afterEach ( ( ) => {
@@ -74,5 +99,8 @@ describe('Trigger.Unique', () => {
74
99
expect ( document . querySelectorAll ( '.rc-trigger-popup-float-bg' ) . length ) . toBe (
75
100
1 ,
76
101
) ;
102
+
103
+ // FloatBg open prop should not have changed during transition (no close animation)
104
+ expect ( global . openChangeLog ) . toHaveLength ( 0 ) ;
77
105
} ) ;
78
106
} ) ;
0 commit comments