test(app): add basic tab tests

This commit is contained in:
2025-07-01 21:57:25 +03:00
parent 135a8a0c39
commit 8ecd9ec8d6
5 changed files with 101 additions and 51 deletions

66
tests/app.rs Normal file
View File

@@ -0,0 +1,66 @@
use traxor::app::App;
#[test]
fn test_app_creation() {
let app = App::new().unwrap();
assert_eq!(app.tabs().len(), 3);
}
#[test]
fn test_app_quit() {
let mut app = App::new().unwrap();
app.quit();
assert!(!app.running);
}
#[test]
fn test_app_next_tab() {
let mut app = App::new().unwrap();
assert_eq!(app.index(), 0);
app.next_tab();
assert_eq!(app.index(), 1);
app.next_tab();
assert_eq!(app.index(), 2);
app.next_tab();
assert_eq!(app.index(), 0); // Wraps around
}
#[test]
fn test_app_prev_tab() {
let mut app = App::new().unwrap();
assert_eq!(app.index(), 0);
app.prev_tab();
assert_eq!(app.index(), 2); // Wraps around
app.prev_tab();
assert_eq!(app.index(), 1);
}
#[test]
fn test_app_switch_tab() {
let mut app = App::new().unwrap();
assert_eq!(app.index(), 0);
app.switch_tab(2);
assert_eq!(app.index(), 2);
app.switch_tab(0);
assert_eq!(app.index(), 0);
}
#[test]
fn test_app_toggle_popup() {
let mut app = App::new().unwrap();
assert!(!app.show_popup);
app.toggle_popup();
assert!(app.show_popup);
app.toggle_popup();
assert!(!app.show_popup);
}
#[test]
fn test_app_open_close_popup() {
let mut app = App::new().unwrap();
assert!(!app.show_popup);
app.open_popup();
assert!(app.show_popup);
app.close_popup();
assert!(!app.show_popup);
}