use crate::tui::app::App;
#[test]
fn esc_less_sgr_burst_is_stripped() {
let poisoned = "File both issues[<35;10;102M[<35;11;102M";
assert_eq!(App::strip_terminal_escapes(poisoned), "File both issues");
}
#[test]
fn esc_less_urxvt_burst_is_stripped() {
let poisoned = "hello[35;10;102M[35;11;102mworld";
assert_eq!(App::strip_terminal_escapes(poisoned), "helloworld");
}
#[test]
fn burst_before_slash_command_is_stripped() {
let poisoned = "[<35;10;102M/compact";
assert_eq!(App::strip_terminal_escapes(poisoned), "/compact");
}
#[test]
fn full_csi_with_esc_still_stripped() {
assert_eq!(App::strip_terminal_escapes("a\x1b[<35;10;102Mb"), "ab");
}
#[test]
fn etx_byte_is_dropped() {
assert_eq!(App::strip_terminal_escapes("foo\x03bar"), "foobar");
}
#[test]
fn bracketed_bounds_text_survives() {
for s in [
"arr[3;4]",
"list[1;2",
"note[<3;4]",
"[<35;10;102",
"a[35;10M b",
"[<M]",
] {
assert_eq!(App::strip_terminal_escapes(s), s, "{s:?} should survive");
}
}
#[test]
fn multibyte_text_survives_burst_strip() {
let s = "héllo 🦀[<35;10;102M";
assert_eq!(App::strip_terminal_escapes(s), "héllo 🦀");
}
#[test]
fn clean_text_fast_path_returns_unchanged() {
let s = "just typing, no brackets at all";
assert_eq!(App::strip_terminal_escapes(s), s);
}
#[test]
fn osc_sequence_stripped_burst_kept() {
let s = "\x1b]0;title\x07keep[3;4]me";
assert_eq!(App::strip_terminal_escapes(s), "keep[3;4]me");
}