use super::layout;
#[test]
fn test_calculate_modal_layout_standard() {
use ratatui::prelude::Rect;
let area = Rect {
x: 0,
y: 0,
width: 120,
height: 40,
};
let (modal_rect, content_rect, keybinds_rect) = layout::calculate_modal_layout(area);
assert!(modal_rect.width <= 96);
assert!(modal_rect.height <= 32);
assert!(modal_rect.x > 0); assert!(modal_rect.y > 0);
assert!(content_rect.width <= modal_rect.width);
assert!(content_rect.height + keybinds_rect.height <= modal_rect.height);
assert_eq!(keybinds_rect.height, 4);
}
#[test]
fn test_calculate_modal_layout_small() {
use ratatui::prelude::Rect;
let area = Rect {
x: 0,
y: 0,
width: 50,
height: 20,
};
let (modal_rect, content_rect, keybinds_rect) = layout::calculate_modal_layout(area);
assert!(modal_rect.width <= area.width);
assert!(modal_rect.height <= area.height);
assert!(content_rect.width <= modal_rect.width);
assert!(content_rect.height + keybinds_rect.height <= modal_rect.height);
}
#[test]
fn test_calculate_modal_layout_max_constraints() {
use ratatui::prelude::Rect;
let area = Rect {
x: 0,
y: 0,
width: 200,
height: 100,
};
let (modal_rect, _, _) = layout::calculate_modal_layout(area);
assert_eq!(modal_rect.width, 96);
assert_eq!(modal_rect.height, 32);
}
#[test]
fn test_calculate_modal_layout_offset() {
use ratatui::prelude::Rect;
let area = Rect {
x: 10,
y: 5,
width: 120,
height: 40,
};
let (modal_rect, _, _) = layout::calculate_modal_layout(area);
assert!(modal_rect.x >= area.x);
assert!(modal_rect.y >= area.y);
assert!(modal_rect.x + modal_rect.width <= area.x + area.width);
assert!(modal_rect.y + modal_rect.height <= area.y + area.height);
}