W52: Tests for editor MarkAll, Close, BlockSave, InsertFile

Add 4 unit tests covering the new W50 editor commands:

- mark_all_selects_entire_buffer: verify selection covers
  the full buffer (start=0, end=buffer.len())
- close_clean_buffer_reopens_empty: verify Close on an
  unmodified buffer resets to an empty buffer
- block_save_on_no_selection_shows_message: verify the
  "No selection" message when nothing is selected
- insert_file_opens_insert_file_prompt: verify the mode
  switches to InsertFile prompt

Tests: 1415 pass (was 1411), zero warnings.
This commit is contained in:
2026-07-07 12:50:00 +03:00
parent 85a82f56d4
commit 69dff0c26c
@@ -3873,5 +3873,45 @@ mod tests {
e.push_goto_history(20);
assert_eq!(e.goto_history, vec![10, 20]);
}
#[test]
fn mark_all_selects_entire_buffer() {
let mut e = make_empty();
e.insert_str("hello world");
// Dispatch MarkAll via the dispatcher.
let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::MarkAll);
let sel = e.cursor.selection();
assert!(sel.is_some());
let (start, end) = sel.unwrap();
assert_eq!(start, 0);
assert_eq!(end, e.buffer.len());
}
#[test]
fn close_clean_buffer_reopens_empty() {
let mut e = make_empty();
e.insert_str("hello");
e.modified = false;
let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::Close);
// Should have reopened as an empty buffer.
assert_eq!(e.buffer.len(), 0);
assert!(!e.modified);
}
#[test]
fn block_save_on_no_selection_shows_message() {
let mut e = make_empty();
e.insert_str("hello");
e.cursor.clear_selection();
let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::BlockSave);
assert_eq!(e.message, Some("No selection".to_string()));
}
#[test]
fn insert_file_opens_insert_file_prompt() {
let mut e = make_empty();
let _ = e.dispatch_editor_cmd(crate::editor::menubar::EditorCmd::InsertFile);
assert!(e.mode.is_prompt());
}
}