diff --git a/training_mod_tui/src/main.rs b/training_mod_tui/src/main.rs index 8b43435..ef7a6af 100644 --- a/training_mod_tui/src/main.rs +++ b/training_mod_tui/src/main.rs @@ -187,6 +187,23 @@ fn test_save_and_reset_defaults() -> Result<(), Box> { Ok(()) } +fn _get_frame_buffer( + mut terminal: Terminal, + mut app: training_mod_tui::App, +) -> Result> { + let frame_res = terminal.draw(|f| training_mod_tui::ui(f, &mut app))?; + let mut full_frame_buffer = String::new(); + for (i, cell) in frame_res.buffer.content().iter().enumerate() { + full_frame_buffer.push_str(&cell.symbol); + if i % frame_res.area.width as usize == frame_res.area.width as usize - 1 { + full_frame_buffer.push_str("\n"); + } + } + full_frame_buffer.push_str("\n"); + + Ok(full_frame_buffer) +} + #[test] fn test_toggle_naming() -> Result<(), Box> { let menu; @@ -204,16 +221,8 @@ fn test_toggle_naming() -> Result<(), Box> { // Set Mash Airdodge app.on_a(); - let frame_res = terminal.draw(|f| training_mod_tui::ui(f, &mut app))?; - let mut full_frame_buffer = String::new(); - for (i, cell) in frame_res.buffer.content().iter().enumerate() { - full_frame_buffer.push_str(&cell.symbol); - if i % frame_res.area.width as usize == frame_res.area.width as usize - 1 { - full_frame_buffer.push_str("\n"); - } - } - full_frame_buffer.push_str("\n"); - assert!(full_frame_buffer.contains("Airdodge")); + let frame_buffer = _get_frame_buffer(terminal, app)?; + assert!(frame_buffer.contains("Airdodge")); Ok(()) }