use justerm_core::Engine;
#[test]
fn accessible_text_includes_scrollback() {
let mut term = Engine::new(10, 2);
for i in 0..5 {
term.feed(format!("line{i}\r\n").as_bytes());
}
assert_eq!(term.accessible_text(), "line0\nline1\nline2\nline3\nline4");
}
#[test]
fn accessible_text_trims_trailing_blank_rows() {
let mut term = Engine::new(20, 24);
term.feed(b"one\r\ntwo");
assert_eq!(term.accessible_text(), "one\ntwo");
}
#[test]
fn accessible_text_fresh_buffer_is_empty() {
let term = Engine::new(20, 24);
assert_eq!(term.accessible_text(), "");
}
#[test]
fn accessible_text_keeps_internal_blank_lines() {
let mut term = Engine::new(10, 4);
term.feed(b"a\r\n\r\nb");
assert_eq!(term.accessible_text(), "a\n\nb");
}
#[test]
fn accessible_text_carries_combining_marks() {
let mut term = Engine::new(10, 1);
term.feed("e\u{0301}".as_bytes());
assert_eq!(term.accessible_text(), "e\u{0301}");
}
#[test]
fn accessible_text_joins_soft_wrapped_rows() {
let mut term = Engine::new(5, 3);
term.feed(b"abcdefgh");
assert!(term.accessible_text().contains("abcdefgh"));
}
#[test]
fn accessible_text_trims_trailing_blanks() {
let mut term = Engine::new(10, 1);
term.feed(b"hi");
assert_eq!(term.accessible_text(), "hi");
}
#[test]
fn accessible_text_emits_wide_glyph_once() {
let mut term = Engine::new(10, 1);
term.feed("가b".as_bytes());
assert_eq!(term.accessible_text(), "가b");
}
#[test]
fn accessible_text_on_alt_shows_only_the_alt_buffer() {
let mut term = Engine::new(10, 2);
for i in 0..4 {
term.feed(format!("p{i}\r\n").as_bytes()); }
term.feed(b"\x1b[?1049h"); term.feed(b"ALT");
let text = term.accessible_text();
assert!(text.contains("ALT"), "alt content shown: {text:?}");
assert!(
!text.contains("p0"),
"primary scrollback hidden on alt: {text:?}"
);
}
#[test]
fn accessible_text_on_alt_joins_wrapped_without_primary_bleed() {
let mut term = Engine::new(5, 2);
for i in 0..4 {
term.feed(format!("p{i}\r\n").as_bytes()); }
term.feed(b"\x1b[?1049h"); term.feed(b"abcdefgh");
let text = term.accessible_text();
assert!(text.contains("abcdefgh"), "wrap-joined on alt: {text:?}");
assert!(
!text.contains("p0"),
"no primary bleed across alt floor: {text:?}"
);
}