@@ -79,21 +79,31 @@ test('waits for element with custom interval', async () => {
79
79
expect ( mockFn ) . toHaveBeenCalledTimes ( 2 ) ;
80
80
} ) ;
81
81
82
- test . each ( [ TimerMode . Legacy , TimerMode . Modern ] ) (
83
- 'waits for element until it stops throwing using %s fake timers' ,
84
- async ( fakeTimerType ) => {
85
- jest . useFakeTimers ( fakeTimerType ) ;
86
- const { getByText, queryByText } = render ( < BananaContainer /> ) ;
82
+ test ( 'waits for element until it stops throwing using modern fake timers' , async ( ) => {
83
+ jest . useFakeTimers ( 'modern' ) ;
84
+ const { getByText, queryByText } = render ( < BananaContainer /> ) ;
87
85
88
- fireEvent . press ( getByText ( 'Change freshness!' ) ) ;
89
- expect ( queryByText ( 'Fresh' ) ) . toBeNull ( ) ;
86
+ fireEvent . press ( getByText ( 'Change freshness!' ) ) ;
87
+ expect ( queryByText ( 'Fresh' ) ) . toBeNull ( ) ;
90
88
91
- jest . advanceTimersByTime ( 300 ) ;
92
- const freshBananaText = await waitFor ( ( ) => getByText ( 'Fresh' ) ) ;
89
+ jest . advanceTimersByTime ( 300 ) ;
90
+ const freshBananaText = await waitFor ( ( ) => getByText ( 'Fresh' ) ) ;
93
91
94
- expect ( freshBananaText . props . children ) . toBe ( 'Fresh' ) ;
95
- }
96
- ) ;
92
+ expect ( freshBananaText . props . children ) . toBe ( 'Fresh' ) ;
93
+ } ) ;
94
+
95
+ test ( 'waits for element until it stops throwing using legacy fake timers' , async ( ) => {
96
+ jest . useFakeTimers ( 'legacy' ) ;
97
+ const { getByText, queryByText } = render ( < BananaContainer /> ) ;
98
+
99
+ fireEvent . press ( getByText ( 'Change freshness!' ) ) ;
100
+ expect ( queryByText ( 'Fresh' ) ) . toBeNull ( ) ;
101
+
102
+ jest . advanceTimersByTime ( 300 ) ;
103
+ const freshBananaText = await waitFor ( ( ) => getByText ( 'Fresh' ) ) ;
104
+
105
+ expect ( freshBananaText . props . children ) . toBe ( 'Fresh' ) ;
106
+ } ) ;
97
107
98
108
test . each ( [ TimerMode . Legacy , TimerMode . Modern ] ) (
99
109
'waits for assertion until timeout is met with %s fake timers' ,
0 commit comments