refactor: Created dedicated proptests and assertions to clean up the handler unit tests
This commit is contained in:
1 parent
35dce0bf01
commit
49fd086b92
46 files changed
+1023
-1018
No files matched your search
@@ -6,6 +6,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::indexers::IndexersHandler;
|
||||
@@ -34,10 +35,7 @@ mod tests {
|
||||
|
||||
IndexersHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt.into()
|
||||
);
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::DeleteIndexerPrompt.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -81,10 +79,7 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::RootFolders.into()
|
||||
);
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::RootFolders.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -105,7 +100,7 @@ mod tests {
|
||||
app.data.radarr_data.main_tabs.get_active_route(),
|
||||
ActiveRadarrBlock::System.into()
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
@@ -125,6 +120,8 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
use super::*;
|
||||
use crate::assert_navigation_popped;
|
||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{
|
||||
@@ -136,8 +133,6 @@ mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::{Number, Value};
|
||||
|
||||
use super::*;
|
||||
|
||||
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
||||
|
||||
#[rstest]
|
||||
@@ -196,10 +191,7 @@ mod tests {
|
||||
|
||||
IndexersHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||
);
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.edit_indexer_modal,
|
||||
Some((&app.data.radarr_data).into())
|
||||
@@ -259,7 +251,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::DeleteIndexer(1))
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -283,7 +275,7 @@ mod tests {
|
||||
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +283,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;
|
||||
|
||||
@@ -310,7 +303,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||
assert!(!app.data.radarr_data.prompt_confirm);
|
||||
}
|
||||
|
||||
@@ -324,7 +317,7 @@ mod tests {
|
||||
|
||||
IndexersHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::TestIndexer, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||
assert_eq!(app.data.radarr_data.indexer_test_errors, None);
|
||||
}
|
||||
|
||||
@@ -338,7 +331,7 @@ mod tests {
|
||||
|
||||
IndexersHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -349,6 +342,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
||||
use crate::{
|
||||
assert_navigation_popped,
|
||||
models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS,
|
||||
network::radarr_network::RadarrEvent,
|
||||
};
|
||||
@@ -371,7 +365,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::Indexers.into());
|
||||
assert!(app.should_refresh);
|
||||
}
|
||||
|
||||
@@ -415,10 +409,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
||||
);
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||
assert_eq!(
|
||||
app.data.radarr_data.selected_block.blocks,
|
||||
INDEXER_SETTINGS_SELECTION_BLOCKS
|
||||
@@ -464,10 +455,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::TestIndexer.into()
|
||||
);
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::TestIndexer.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -509,10 +497,7 @@ mod tests {
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveRadarrBlock::TestAllIndexers.into()
|
||||
);
|
||||
assert_navigation_pushed!(app, ActiveRadarrBlock::TestAllIndexers.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -557,7 +542,7 @@ mod tests {
|
||||
app.data.radarr_data.prompt_confirm_action,
|
||||
Some(RadarrEvent::DeleteIndexer(1))
|
||||
);
|
||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user