@@ -169,6 +169,23 @@ impl Gitui {
169
169
. unwrap ( ) ;
170
170
}
171
171
172
+ #[ cfg( test) ]
173
+ fn wait_for_async_git_notification (
174
+ & self ,
175
+ expected : AsyncGitNotification ,
176
+ ) {
177
+ loop {
178
+ let actual = self
179
+ . rx_git
180
+ . recv_timeout ( std:: time:: Duration :: from_millis ( 100 ) )
181
+ . unwrap ( ) ;
182
+
183
+ if actual == expected {
184
+ break ;
185
+ }
186
+ }
187
+ }
188
+
172
189
#[ cfg( test) ]
173
190
fn update ( & mut self ) {
174
191
self . app . update ( ) . unwrap ( ) ;
@@ -177,7 +194,7 @@ impl Gitui {
177
194
178
195
#[ cfg( test) ]
179
196
mod tests {
180
- use std:: { path:: PathBuf , thread :: sleep , time :: Duration } ;
197
+ use std:: path:: PathBuf ;
181
198
182
199
use asyncgit:: { sync:: RepoPath , AsyncGitNotification } ;
183
200
use crossterm:: event:: { KeyCode , KeyModifiers } ;
@@ -225,16 +242,12 @@ mod tests {
225
242
226
243
gitui. draw ( & mut terminal) . unwrap ( ) ;
227
244
228
- sleep ( Duration :: from_millis ( 500 ) ) ;
229
-
230
245
assert_snapshot ! ( "app_loading" , terminal. backend( ) ) ;
231
246
232
247
let event =
233
248
AsyncNotification :: Git ( AsyncGitNotification :: Status ) ;
234
249
gitui. update_async ( event) ;
235
250
236
- sleep ( Duration :: from_millis ( 500 ) ) ;
237
-
238
251
gitui. draw ( & mut terminal) . unwrap ( ) ;
239
252
240
253
assert_snapshot ! ( "app_loading_finished" , terminal. backend( ) ) ;
@@ -245,7 +258,9 @@ mod tests {
245
258
key_config. keys . tab_log . modifiers ,
246
259
) ;
247
260
248
- sleep ( Duration :: from_millis ( 500 ) ) ;
261
+ gitui. wait_for_async_git_notification (
262
+ AsyncGitNotification :: Log ,
263
+ ) ;
249
264
250
265
gitui. update ( ) ;
251
266
0 commit comments