use frentui::app::App;
use frentui::section::{SectionId, SectionTrait};
use frentui::ui::section_layout;
#[test]
fn test_section_heights_defined() {
let app = App::new();
for section in &app.sections {
let heights = section.heights();
assert!(heights.min_total() <= heights.max_total());
assert!(heights.note_min <= heights.note_max);
assert!(heights.content_min <= heights.content_max);
assert!(heights.actions_min <= heights.actions_max);
}
}
#[test]
fn test_section_min_height() {
let app = App::new();
let preview_section = app.sections.iter().find(|s| s.id() == SectionId::PreviewPane).unwrap();
let validation_section = app.sections.iter().find(|s| s.id() == SectionId::Validation).unwrap();
let working_dir_section = app.sections.iter().find(|s| s.id() == SectionId::WorkingDirectory).unwrap();
let preview_min = preview_section.heights().min_total();
let validation_min = validation_section.heights().min_total();
let working_dir_min = working_dir_section.heights().min_total();
assert!(preview_min >= 3);
assert!(validation_min >= 3);
assert!(working_dir_min >= 3);
}
#[test]
fn test_calculate_section_height_preview() {
let app = App::new();
let preview_section = app.sections.iter().find(|s| s.id() == SectionId::PreviewPane).unwrap();
let height_empty = section_layout::calculate_section_height(
preview_section,
&app,
100
);
assert!(height_empty >= 3);
assert!(height_empty > 0);
}
#[test]
fn test_calculate_section_height_validation() {
let app = App::new();
let validation_section = app.sections.iter().find(|s| s.id() == SectionId::Validation).unwrap();
let height_no_validation = section_layout::calculate_section_height(
validation_section,
&app,
100
);
assert!(height_no_validation >= 3);
}
#[test]
fn test_calculate_section_height_fixed_sections() {
let app = App::new();
let working_dir_section = app.sections.iter().find(|s| s.id() == SectionId::WorkingDirectory).unwrap();
let working_dir_height = section_layout::calculate_section_height(
working_dir_section,
&app,
100
);
assert!(working_dir_height >= 8);
assert!(working_dir_height <= 10);
let match_files_section = app.sections.iter().find(|s| s.id() == SectionId::MatchFiles).unwrap();
let match_files_height = section_layout::calculate_section_height(
match_files_section,
&app,
100
);
assert!(match_files_height >= 8);
assert!(match_files_height <= 10);
assert!(working_dir_height == 8 || working_dir_height == 10);
assert!(match_files_height == 8 || match_files_height == 10);
}
#[test]
fn test_section_heights_respect_available_height() {
let app = App::new();
let preview_section = app.sections.iter().find(|s| s.id() == SectionId::PreviewPane).unwrap();
let available = 10;
let height = section_layout::calculate_section_height(
preview_section,
&app,
available
);
assert!(height <= available);
}