use par_term::config::{Config, TabBarMode, TabBarPosition};
use par_term::tab_bar_ui::TabBarUI;
#[test]
fn test_tab_bar_ui_creation() {
let tab_bar = TabBarUI::new();
assert!(tab_bar.hovered_tab.is_none());
assert!(tab_bar.close_hovered.is_none());
assert!(!tab_bar.is_context_menu_open());
}
#[test]
fn test_tab_bar_ui_default() {
let tab_bar = TabBarUI::default();
assert!(tab_bar.hovered_tab.is_none());
assert!(tab_bar.close_hovered.is_none());
}
#[test]
fn test_tab_bar_should_show_always() {
let tab_bar = TabBarUI::new();
assert!(tab_bar.should_show(0, TabBarMode::Always));
assert!(tab_bar.should_show(1, TabBarMode::Always));
assert!(tab_bar.should_show(2, TabBarMode::Always));
assert!(tab_bar.should_show(100, TabBarMode::Always));
}
#[test]
fn test_tab_bar_should_show_when_multiple() {
let tab_bar = TabBarUI::new();
assert!(!tab_bar.should_show(0, TabBarMode::WhenMultiple));
assert!(!tab_bar.should_show(1, TabBarMode::WhenMultiple));
assert!(tab_bar.should_show(2, TabBarMode::WhenMultiple));
assert!(tab_bar.should_show(10, TabBarMode::WhenMultiple));
}
#[test]
fn test_tab_bar_should_show_never() {
let tab_bar = TabBarUI::new();
assert!(!tab_bar.should_show(0, TabBarMode::Never));
assert!(!tab_bar.should_show(1, TabBarMode::Never));
assert!(!tab_bar.should_show(2, TabBarMode::Never));
assert!(!tab_bar.should_show(100, TabBarMode::Never));
}
#[test]
fn test_tab_bar_height_when_hidden() {
let tab_bar = TabBarUI::new();
let config = Config {
tab_bar_mode: TabBarMode::WhenMultiple,
..Config::default()
};
assert_eq!(tab_bar.get_height(1, &config), 0.0);
}
#[test]
fn test_tab_bar_height_when_visible() {
let tab_bar = TabBarUI::new();
let config = Config::default();
assert_eq!(tab_bar.get_height(2, &config), config.tab_bar_height);
}
#[test]
fn test_tab_bar_context_menu_initially_closed() {
let tab_bar = TabBarUI::new();
assert!(!tab_bar.is_context_menu_open());
}
#[test]
fn test_close_hovered_state_init() {
let tab_bar = TabBarUI::new();
assert!(
tab_bar.close_hovered.is_none(),
"No close button should be hovered on init"
);
}
#[test]
fn test_tab_bar_uses_config_height() {
let tab_bar = TabBarUI::new();
let mut config = Config::default();
let default_height = tab_bar.get_height(2, &config);
assert!(default_height > 0.0);
config.tab_bar_height = 50.0;
let custom_height = tab_bar.get_height(2, &config);
assert_eq!(custom_height, 50.0, "Tab bar should use config height");
}
#[test]
fn test_tab_bar_height_zero_when_hidden() {
let tab_bar = TabBarUI::new();
let config = Config {
tab_bar_mode: TabBarMode::WhenMultiple,
..Config::default()
};
let height = tab_bar.get_height(1, &config);
assert_eq!(height, 0.0, "Tab bar should have 0 height when hidden");
}
#[test]
fn test_should_show_edge_case_zero_tabs() {
let tab_bar = TabBarUI::new();
assert!(tab_bar.should_show(0, TabBarMode::Always));
assert!(!tab_bar.should_show(0, TabBarMode::WhenMultiple));
assert!(!tab_bar.should_show(0, TabBarMode::Never));
}
#[test]
fn test_tab_bar_height_with_edge_case_heights() {
let tab_bar = TabBarUI::new();
let config_small = Config {
tab_bar_height: 1.0,
..Config::default()
};
let small = tab_bar.get_height(2, &config_small);
assert_eq!(small, 1.0);
let config_large = Config {
tab_bar_height: 1000.0,
..Config::default()
};
let large = tab_bar.get_height(2, &config_large);
assert_eq!(large, 1000.0);
let config_zero = Config {
tab_bar_height: 0.0,
..Config::default()
};
let zero = tab_bar.get_height(2, &config_zero);
assert_eq!(zero, 0.0);
}
#[test]
fn test_tab_bar_position_default_is_top() {
let config = Config::default();
assert_eq!(config.tab_bar_position, TabBarPosition::Top);
}
#[test]
fn test_tab_bar_height_zero_for_left_position() {
let tab_bar = TabBarUI::new();
let config = Config {
tab_bar_position: TabBarPosition::Left,
..Config::default()
};
assert_eq!(tab_bar.get_height(2, &config), 0.0);
assert_eq!(tab_bar.get_height(10, &config), 0.0);
}
#[test]
fn test_tab_bar_width_zero_for_top_bottom() {
let tab_bar = TabBarUI::new();
let config_top = Config {
tab_bar_position: TabBarPosition::Top,
..Config::default()
};
assert_eq!(tab_bar.get_width(2, &config_top), 0.0);
let config_bottom = Config {
tab_bar_position: TabBarPosition::Bottom,
..Config::default()
};
assert_eq!(tab_bar.get_width(2, &config_bottom), 0.0);
}
#[test]
fn test_tab_bar_width_for_left_position() {
let tab_bar = TabBarUI::new();
let config = Config {
tab_bar_position: TabBarPosition::Left,
tab_bar_width: 200.0,
..Config::default()
};
assert_eq!(tab_bar.get_width(2, &config), 200.0);
}
#[test]
fn test_tab_bar_width_respects_tab_bar_mode() {
let tab_bar = TabBarUI::new();
let config = Config {
tab_bar_position: TabBarPosition::Left,
tab_bar_width: 200.0,
tab_bar_mode: TabBarMode::WhenMultiple,
..Config::default()
};
assert_eq!(tab_bar.get_width(1, &config), 0.0);
assert_eq!(tab_bar.get_width(2, &config), 200.0);
}
#[test]
fn test_tab_bar_height_for_top_and_bottom() {
let tab_bar = TabBarUI::new();
let config_top = Config {
tab_bar_position: TabBarPosition::Top,
tab_bar_height: 30.0,
..Config::default()
};
assert_eq!(tab_bar.get_height(2, &config_top), 30.0);
let config_bottom = Config {
tab_bar_position: TabBarPosition::Bottom,
tab_bar_height: 30.0,
..Config::default()
};
assert_eq!(tab_bar.get_height(2, &config_bottom), 30.0);
}
#[test]
fn test_tab_bar_position_is_horizontal() {
assert!(TabBarPosition::Top.is_horizontal());
assert!(TabBarPosition::Bottom.is_horizontal());
assert!(!TabBarPosition::Left.is_horizontal());
}
#[test]
fn test_tab_bar_position_display_names() {
assert_eq!(TabBarPosition::Top.display_name(), "Top");
assert_eq!(TabBarPosition::Bottom.display_name(), "Bottom");
assert_eq!(TabBarPosition::Left.display_name(), "Left");
}
#[test]
fn test_tab_bar_position_all() {
let all_positions = TabBarPosition::all();
assert_eq!(all_positions.len(), 3);
assert!(all_positions.contains(&TabBarPosition::Top));
assert!(all_positions.contains(&TabBarPosition::Bottom));
assert!(all_positions.contains(&TabBarPosition::Left));
}