File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ export default function useStatus(
126126 }
127127 } , [ status ] ) ;
128128
129- const [ startStep , step ] = useStepQueue ( ( newStep ) => {
129+ const [ startStep , step ] = useStepQueue ( status , ( newStep ) => {
130130 // Only prepare step can be skip
131131 if ( newStep === STEP_PREPARE ) {
132132 const onPrepare = eventHandlers [ STEP_PREPARE ] ;
Original file line number Diff line number Diff line change 66 STEP_START ,
77 STEP_ACTIVATED ,
88 STEP_NONE ,
9+ MotionStatus ,
910} from '../interface' ;
1011import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect' ;
1112import useNextFrame from './useNextFrame' ;
@@ -27,6 +28,7 @@ export function isActive(step: StepStatus) {
2728}
2829
2930export default (
31+ status : MotionStatus ,
3032 callback : (
3133 step : StepStatus ,
3234 ) => Promise < void > | void | typeof SkipStep | typeof DoStep ,
@@ -68,7 +70,7 @@ export default (
6870 } ) ;
6971 }
7072 }
71- } , [ step ] ) ;
73+ } , [ status , step ] ) ;
7274
7375 React . useEffect (
7476 ( ) => ( ) => {
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ describe('CSSMotion', () => {
186186 expect ( boxNode . hasClass ( 'transition-appear-active' ) ) . toBeFalsy ( ) ;
187187 } ) ;
188188
189- it ( 'quick switch should have correct status' , ( ) => {
189+ it ( 'quick switch should have correct status' , async ( ) => {
190190 const wrapper = mount (
191191 < CSSMotion motionName = "transition" >
192192 { ( { style, className } ) => (
@@ -208,7 +208,23 @@ describe('CSSMotion', () => {
208208 wrapper . update ( ) ;
209209 } ) ;
210210
211- const boxNode = wrapper . find ( '.motion-box' ) ;
211+ let boxNode = wrapper . find ( '.motion-box' ) ;
212+ expect ( boxNode . hasClass ( 'transition' ) ) . toBeTruthy ( ) ;
213+ expect ( boxNode . hasClass ( 'transition-leave' ) ) . toBeTruthy ( ) ;
214+ expect ( boxNode . hasClass ( 'transition-leave-active' ) ) . toBeTruthy ( ) ;
215+
216+ wrapper . setProps ( { visible : true } ) ;
217+ await act ( ( ) => {
218+ return Promise . resolve ( ) . then ( ( ) => {
219+ wrapper . setProps ( { visible : false } ) ;
220+ } ) ;
221+ } ) ;
222+ act ( ( ) => {
223+ jest . runAllTimers ( ) ;
224+ wrapper . update ( ) ;
225+ } ) ;
226+
227+ boxNode = wrapper . find ( '.motion-box' ) ;
212228 expect ( boxNode . hasClass ( 'transition' ) ) . toBeTruthy ( ) ;
213229 expect ( boxNode . hasClass ( 'transition-leave' ) ) . toBeTruthy ( ) ;
214230 expect ( boxNode . hasClass ( 'transition-leave-active' ) ) . toBeTruthy ( ) ;
You can’t perform that action at this time.
0 commit comments