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