@@ -325,100 +325,3 @@ fn set_panic_handlers() -> Result<()> {
325325
326326 Ok ( ( ) )
327327}
328-
329- #[ cfg( test) ]
330- mod tests {
331- use std:: {
332- cell:: RefCell , path:: PathBuf , thread:: sleep, time:: Duration ,
333- } ;
334-
335- use asyncgit:: { sync:: RepoPath , AsyncGitNotification } ;
336- use crossbeam_channel:: unbounded;
337- use git2_testing:: repo_init;
338- use insta:: assert_snapshot;
339- use ratatui:: { backend:: TestBackend , Terminal } ;
340-
341- use crate :: {
342- app:: App , draw, input:: Input , keys:: KeyConfig ,
343- ui:: style:: Theme , AsyncNotification ,
344- } ;
345-
346- // Macro adapted from: https://insta.rs/docs/cmd/
347- macro_rules! apply_common_filters {
348- { } => {
349- let mut settings = insta:: Settings :: clone_current( ) ;
350- // MacOS Temp Folder
351- settings. add_filter( r" *\[…\]\S+?/T/\S+" , "[TEMP_FILE]" ) ;
352- // Linux Temp Folder
353- settings. add_filter( r" */tmp/\.tmp\S+" , "[TEMP_FILE]" ) ;
354- // Windows Temp folder
355- settings. add_filter( r" *\[…\].*/Local/Temp/\S+" , "[TEMP_FILE]" ) ;
356- // Commit ids that follow a vertical bar
357- settings. add_filter( r"│[a-z0-9]{7} " , "│[AAAAA] " ) ;
358- let _bound = settings. bind_to_scope( ) ;
359- }
360- }
361-
362- #[ test]
363- fn app_starts ( ) {
364- apply_common_filters ! ( ) ;
365-
366- let ( temp_dir, _repo) = repo_init ( ) ;
367- let path: RepoPath = temp_dir. path ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
368-
369- let ( tx_git, _rx_git) = unbounded ( ) ;
370- let ( tx_app, _rx_app) = unbounded ( ) ;
371-
372- let input = Input :: new ( ) ;
373-
374- let theme = Theme :: init ( & PathBuf :: new ( ) ) ;
375- let key_config = KeyConfig :: default ( ) ;
376-
377- let mut app = App :: new (
378- RefCell :: new ( path) ,
379- tx_git,
380- tx_app,
381- input. clone ( ) ,
382- theme,
383- key_config. clone ( ) ,
384- )
385- . unwrap ( ) ;
386-
387- let mut terminal =
388- Terminal :: new ( TestBackend :: new ( 120 , 40 ) ) . unwrap ( ) ;
389-
390- draw ( & mut terminal, & app) . unwrap ( ) ;
391-
392- assert_snapshot ! ( "app_loading" , terminal. backend( ) ) ;
393-
394- let event =
395- AsyncNotification :: Git ( AsyncGitNotification :: Status ) ;
396- app. update_async ( event) . unwrap ( ) ;
397-
398- sleep ( Duration :: from_millis ( 500 ) ) ;
399-
400- draw ( & mut terminal, & app) . unwrap ( ) ;
401-
402- assert_snapshot ! ( "app_loading_finished" , terminal. backend( ) ) ;
403-
404- let event = crossterm:: event:: KeyEvent :: new (
405- key_config. keys . tab_log . code ,
406- key_config. keys . tab_log . modifiers ,
407- ) ;
408- app. event ( crate :: input:: InputEvent :: Input (
409- crossterm:: event:: Event :: Key ( event) ,
410- ) )
411- . unwrap ( ) ;
412-
413- sleep ( Duration :: from_millis ( 500 ) ) ;
414-
415- app. update ( ) . unwrap ( ) ;
416-
417- draw ( & mut terminal, & app) . unwrap ( ) ;
418-
419- assert_snapshot ! (
420- "app_log_tab_showing_one_commit" ,
421- terminal. backend( )
422- ) ;
423- }
424- }
0 commit comments