Compare commits

..

1 Commits

Author SHA1 Message Date
41b67ebd60 wip: test coverage for copy paste 2024-12-27 20:47:10 -05:00
2 changed files with 6 additions and 80 deletions

View File

@ -652,7 +652,6 @@ impl<'ws> Workspace<'ws> {
match key.code {
KeyCode::Esc => {
self.state.reset_n_prefix();
self.state.char_queue.clear();
}
KeyCode::Char(d) if d.is_ascii_digit() => {
self.handle_numeric_prefix(d);
@ -728,6 +727,12 @@ impl<'ws> Workspace<'ws> {
Ok(())
})?;
}
KeyCode::Char('s')
if key.modifiers == KeyModifiers::HYPER
|| key.modifiers == KeyModifiers::SUPER =>
{
self.save_file()?;
}
KeyCode::Char('l') if key.modifiers == KeyModifiers::CONTROL => {
self.run_with_prefix(|ws: &mut Workspace<'_>| -> Result<()> {
let Address { row: _, col } = &ws.book.location;

View File

@ -563,82 +563,3 @@ fn test_traditional_copy_paste_rendered() {
"3",
);
}
#[test]
fn test_clear_cell() {
let mut ws =
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
ws.book.edit_current_cell("foo")
.expect("failed to edit cell");
ws.book.evaluate();
assert_eq!("foo", ws.book.get_current_cell_contents().expect("failed to get cell contents"));
InputScript::default()
.add_char('d')
.run(&mut ws)
.expect("Failed to run input script");
assert_eq!("", ws.book.get_current_cell_contents().expect("failed to get cell contents"));
}
#[test]
fn test_clear_cell_all() {
let mut ws =
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
ws.book.edit_current_cell("foo")
.expect("failed to edit cell");
ws.book.evaluate();
assert_eq!("foo", ws.book.get_current_cell_contents().expect("failed to get cell contents"));
InputScript::default()
.add_char('D')
.run(&mut ws)
.expect("Failed to run input script");
assert_eq!("", ws.book.get_current_cell_contents().expect("failed to get cell contents"));
}
#[test]
fn test_sheet_navigation() {
let mut ws =
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
ws.book.new_sheet(Some("sheet 2")).expect("Failed to set sheet name");
ws.book.new_sheet(Some("sheet 3")).expect("Failed to set sheet name");
ws.book.new_sheet(Some("sheet 4")).expect("Failed to set sheet name");
InputScript::default()
.add_modified_char('n', KeyModifiers::CONTROL)
.add_modified_char('n', KeyModifiers::CONTROL)
.run(&mut ws)
.expect("Failed to run input script");
assert_eq!("sheet 3", ws.book.get_sheet_name().expect("Failed to get sheet name"));
InputScript::default()
.add_modified_char('p', KeyModifiers::CONTROL)
.run(&mut ws)
.expect("Failed to run input script");
assert_eq!("sheet 2", ws.book.get_sheet_name().expect("Failed to get sheet name"));
}
#[test]
fn test_sheet_column_sizing() {
let mut ws =
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
InputScript::default()
.add_char('3')
.add_modified_char('l', KeyModifiers::CONTROL)
.run(&mut ws)
.expect("Failed to run input script");
assert_eq!(28, ws.book.get_col_size(1).expect("Failed to get column size"));
InputScript::default()
.add_char('1')
.add_modified_char('h', KeyModifiers::CONTROL)
.run(&mut ws)
.expect("Failed to run input script");
assert_eq!(27, ws.book.get_col_size(1).expect("Failed to get column size"));
}
#[test]
fn test_quit() {
let mut ws =
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
let result = InputScript::default()
.add_char('q')
.run(&mut ws)
.expect("Failed to run input script");
assert!(result.is_some());
}