use ratatui::style::Color;
use crate::ui::helpers::{format_bytes, scroll_indicator, usage_color, usage_color_f64};
#[test]
fn test_format_bytes_zero() {
assert_eq!(format_bytes(0), "0 B");
}
#[test]
fn test_format_bytes_one_byte() {
assert_eq!(format_bytes(1), "1 B");
}
#[test]
fn test_format_bytes_below_kib() {
assert_eq!(format_bytes(1023), "1023 B");
}
#[test]
fn test_format_bytes_one_kib() {
assert_eq!(format_bytes(1024), "1.0 KiB");
}
#[test]
fn test_format_bytes_fractional_kib() {
assert_eq!(format_bytes(1536), "1.5 KiB");
}
#[test]
fn test_format_bytes_below_mib() {
let s = format_bytes(1_048_575);
assert!(s.ends_with(" KiB"), "expected KiB suffix, got: {s}");
}
#[test]
fn test_format_bytes_one_mib() {
assert_eq!(format_bytes(1_048_576), "1.0 MiB");
}
#[test]
fn test_format_bytes_one_gib() {
assert_eq!(format_bytes(1_073_741_824), "1.0 GiB");
}
#[test]
fn test_format_bytes_fractional_gib() {
assert_eq!(format_bytes(4_831_838_208), "4.5 GiB");
}
#[test]
fn test_usage_color_low_is_green() {
assert_eq!(usage_color(0.0), Color::Green);
assert_eq!(usage_color(25.0), Color::Green);
assert_eq!(usage_color(49.9), Color::Green);
}
#[test]
fn test_usage_color_boundary_50_is_yellow() {
assert_eq!(usage_color(50.0), Color::Yellow);
}
#[test]
fn test_usage_color_mid_is_yellow() {
assert_eq!(usage_color(65.0), Color::Yellow);
assert_eq!(usage_color(79.9), Color::Yellow);
}
#[test]
fn test_usage_color_boundary_80_is_red() {
assert_eq!(usage_color(80.0), Color::Red);
}
#[test]
fn test_usage_color_high_is_red() {
assert_eq!(usage_color(95.0), Color::Red);
assert_eq!(usage_color(100.0), Color::Red);
}
#[test]
fn test_usage_color_f64_matches_f32() {
assert_eq!(usage_color_f64(0.0), Color::Green);
assert_eq!(usage_color_f64(50.0), Color::Yellow);
assert_eq!(usage_color_f64(80.0), Color::Red);
}
#[test]
fn test_scroll_indicator_both() {
assert_eq!(scroll_indicator(true, true), " ▲▼");
}
#[test]
fn test_scroll_indicator_up_only() {
assert_eq!(scroll_indicator(true, false), " ▲");
}
#[test]
fn test_scroll_indicator_down_only() {
assert_eq!(scroll_indicator(false, true), " ▼");
}
#[test]
fn test_scroll_indicator_neither() {
assert_eq!(scroll_indicator(false, false), "");
}