Skip to content

Commit

Permalink
Remove tests that have been moved to Gitui
Browse files Browse the repository at this point in the history
  • Loading branch information
cruessler committed Nov 20, 2024
1 parent 2c71c67 commit 65901fd
Showing 1 changed file with 0 additions and 97 deletions.
97 changes: 0 additions & 97 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,100 +304,3 @@ fn set_panic_handlers() -> Result<()> {

Ok(())
}

#[cfg(test)]
mod tests {
use std::{
cell::RefCell, path::PathBuf, thread::sleep, time::Duration,
};

use asyncgit::{sync::RepoPath, AsyncGitNotification};
use crossbeam_channel::unbounded;
use git2_testing::repo_init;
use insta::assert_snapshot;
use ratatui::{backend::TestBackend, Terminal};

use crate::{
app::App, draw, input::Input, keys::KeyConfig,
ui::style::Theme, AsyncNotification,
};

// Macro adapted from: https://insta.rs/docs/cmd/
macro_rules! apply_common_filters {
{} => {
let mut settings = insta::Settings::clone_current();
// MacOS Temp Folder
settings.add_filter(r" *\[…\]\S+?/T/\S+", "[TEMP_FILE]");
// Linux Temp Folder
settings.add_filter(r" */tmp/\.tmp\S+", "[TEMP_FILE]");
// Windows Temp folder
settings.add_filter(r" *\[…\].*/Local/Temp/\S+", "[TEMP_FILE]");
// Commit ids that follow a vertical bar
settings.add_filter(r"│[a-z0-9]{7} ", "│[AAAAA] ");
let _bound = settings.bind_to_scope();
}
}

#[test]
fn app_starts() {
apply_common_filters!();

let (temp_dir, _repo) = repo_init();
let path: RepoPath = temp_dir.path().to_str().unwrap().into();

let (tx_git, _rx_git) = unbounded();
let (tx_app, _rx_app) = unbounded();

let input = Input::new();

let theme = Theme::init(&PathBuf::new());
let key_config = KeyConfig::default();

let mut app = App::new(
RefCell::new(path),
tx_git,
tx_app,
input.clone(),
theme,
key_config.clone(),
)
.unwrap();

let mut terminal =
Terminal::new(TestBackend::new(120, 40)).unwrap();

draw(&mut terminal, &app).unwrap();

assert_snapshot!("app_loading", terminal.backend());

let event =
AsyncNotification::Git(AsyncGitNotification::Status);
app.update_async(event).unwrap();

sleep(Duration::from_millis(500));

draw(&mut terminal, &app).unwrap();

assert_snapshot!("app_loading_finished", terminal.backend());

let event = crossterm::event::KeyEvent::new(
key_config.keys.tab_log.code,
key_config.keys.tab_log.modifiers,
);
app.event(crate::input::InputEvent::Input(
crossterm::event::Event::Key(event),
))
.unwrap();

sleep(Duration::from_millis(500));

app.update().unwrap();

draw(&mut terminal, &app).unwrap();

assert_snapshot!(
"app_log_tab_showing_one_commit",
terminal.backend()
);
}
}

0 comments on commit 65901fd

Please sign in to comment.