refactor: Created dedicated proptests and assertions to clean up the handler unit tests

This commit is contained in:
2025-12-04 22:57:06 -07:00
parent 35dce0bf01
commit 49fd086b92
46 changed files with 1023 additions and 1018 deletions
@@ -5,6 +5,7 @@ mod tests {
use crate::app::App;
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
use crate::assert_navigation_pushed;
use crate::event::Key;
use crate::handlers::KeyEventHandler;
use crate::handlers::radarr_handlers::system::SystemHandler;
@@ -19,6 +20,7 @@ mod tests {
use pretty_assertions::assert_eq;
use super::*;
use crate::assert_navigation_pushed;
#[rstest]
fn test_system_tab_left(#[values(true, false)] is_ready: bool) {
@@ -38,7 +40,7 @@ mod tests {
app.data.radarr_data.main_tabs.get_active_route(),
ActiveRadarrBlock::Indexers.into()
);
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
assert_navigation_pushed!(app, ActiveRadarrBlock::Indexers.into());
}
#[rstest]
@@ -59,7 +61,7 @@ mod tests {
app.data.radarr_data.main_tabs.get_active_route(),
ActiveRadarrBlock::Movies.into()
);
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
assert_navigation_pushed!(app, ActiveRadarrBlock::Movies.into());
}
}
@@ -67,6 +69,7 @@ mod tests {
use pretty_assertions::assert_eq;
use super::*;
use crate::{assert_navigation_popped, assert_navigation_pushed};
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
@@ -80,7 +83,7 @@ mod tests {
SystemHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::System, None).handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
assert_navigation_popped!(app, ActiveRadarrBlock::System.into());
assert!(app.error.text.is_empty());
}
}
@@ -118,10 +121,7 @@ mod tests {
)
.handle();
assert_eq!(
app.get_current_route(),
ActiveRadarrBlock::SystemUpdates.into()
);
assert_navigation_pushed!(app, ActiveRadarrBlock::SystemUpdates.into());
}
#[test]
@@ -181,10 +181,7 @@ mod tests {
)
.handle();
assert_eq!(
app.get_current_route(),
ActiveRadarrBlock::SystemQueuedEvents.into()
);
assert_navigation_pushed!(app, ActiveRadarrBlock::SystemQueuedEvents.into());
}
#[test]
@@ -245,7 +242,7 @@ mod tests {
)
.handle();
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
assert_navigation_pushed!(app, ActiveRadarrBlock::System.into());
assert!(app.should_refresh);
}
@@ -308,10 +305,7 @@ mod tests {
)
.handle();
assert_eq!(
app.get_current_route(),
ActiveRadarrBlock::SystemLogs.into()
);
assert_navigation_pushed!(app, ActiveRadarrBlock::SystemLogs.into());
assert_eq!(
app.data.radarr_data.log_details.items,
app.data.radarr_data.logs.items
@@ -380,10 +374,7 @@ mod tests {
)
.handle();
assert_eq!(
app.get_current_route(),
ActiveRadarrBlock::SystemTasks.into()
);
assert_navigation_pushed!(app, ActiveRadarrBlock::SystemTasks.into());
}
#[test]