Implemented unit tests for ui utils

This commit is contained in:
2023-08-08 10:50:05 -06:00
parent e9b37e23ae
commit 110da1c0ee
6 changed files with 429 additions and 23 deletions
+4 -4
View File
@@ -8,9 +8,9 @@ use crate::app::radarr::ActiveRadarrBlock;
use crate::models::radarr_models::AddMovieSearchResult;
use crate::models::Route;
use crate::ui::utils::{
borderless_block, get_width, horizontal_chunks, layout_block, layout_paragraph_borderless,
show_cursor, style_default, style_help, style_primary, title_block_centered,
vertical_chunks_with_margin,
borderless_block, get_width_with_margin, horizontal_chunks, layout_block,
layout_paragraph_borderless, show_cursor, style_default, style_help, style_primary,
title_block_centered, vertical_chunks_with_margin,
};
use crate::ui::{
draw_button, draw_drop_down_list, draw_drop_down_menu_button, draw_drop_down_popup,
@@ -146,7 +146,7 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
movie
.title
.scroll_or_reset(get_width(area), *movie == current_selection);
.scroll_or_reset(get_width_with_margin(area), *movie == current_selection);
Row::new(vec![
Cell::from(movie.title.to_string()),
+8 -5
View File
@@ -18,10 +18,10 @@ use crate::ui::radarr_ui::add_movie_ui::draw_add_movie_search_popup;
use crate::ui::radarr_ui::collection_details_ui::draw_collection_details_popup;
use crate::ui::radarr_ui::movie_details_ui::draw_movie_info_popup;
use crate::ui::utils::{
borderless_block, get_width, horizontal_chunks, layout_block, layout_block_top_border,
line_gauge_with_label, line_gauge_with_title, show_cursor, style_bold, style_default,
style_failure, style_primary, style_success, style_warning, title_block, title_block_centered,
vertical_chunks_with_margin,
borderless_block, get_width_with_margin, horizontal_chunks, layout_block,
layout_block_top_border, line_gauge_with_label, line_gauge_with_title, show_cursor, style_bold,
style_default, style_failure, style_primary, style_success, style_warning, title_block,
title_block_centered, vertical_chunks_with_margin,
};
use crate::ui::{
draw_large_popup_over, draw_popup_over, draw_prompt_box, draw_prompt_popup_over, draw_table,
@@ -385,7 +385,10 @@ fn draw_downloads<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
} = download_record;
let path = output_path.clone().unwrap_or_default();
path.scroll_or_reset(get_width(area), current_selection == *download_record);
path.scroll_or_reset(
get_width_with_margin(area),
current_selection == *download_record,
);
let percent = 1f64 - (sizeleft.as_f64().unwrap() / size.as_f64().unwrap());
let file_size: f64 = convert_to_gb(size.as_u64().unwrap());
+2 -2
View File
@@ -12,7 +12,7 @@ use crate::app::App;
use crate::models::radarr_models::{Credit, MovieHistoryItem, Release};
use crate::models::Route;
use crate::ui::utils::{
borderless_block, get_width, layout_block_bottom_border, layout_block_top_border,
borderless_block, get_width_with_margin, layout_block_bottom_border, layout_block_top_border,
spans_info_default, style_bold, style_default, style_failure, style_primary, style_success,
style_warning, vertical_chunks,
};
@@ -393,7 +393,7 @@ fn draw_movie_releases<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, content_
} = release;
let age = format!("{} days", age.as_u64().unwrap_or(0));
title.scroll_or_reset(
get_width(content_area),
get_width_with_margin(content_area),
current_selection == *release
&& current_route != ActiveRadarrBlock::ManualSearchConfirmPrompt.into(),
);