2021-08-06 00:40:45 +00:00
|
|
|
pub mod helper;
|
|
|
|
|
|
|
|
use crate::helper::{TestOp::*, *};
|
|
|
|
|
|
|
|
#[test]
|
2021-08-06 14:25:09 +00:00
|
|
|
fn delta_undo_insert() {
|
2021-08-06 15:06:27 +00:00
|
|
|
let ops = vec![
|
|
|
|
//
|
|
|
|
Insert(0, "\n", 0),
|
|
|
|
Insert(0, "123", 0),
|
|
|
|
Undo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
|
|
|
];
|
2021-08-06 00:40:45 +00:00
|
|
|
OpTester::new().run_script(ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-08-06 14:25:09 +00:00
|
|
|
fn delta_undo_insert2() {
|
2021-08-06 00:40:45 +00:00
|
|
|
let ops = vec![
|
2021-08-06 15:06:27 +00:00
|
|
|
Insert(0, "\n", 0),
|
2021-08-06 00:40:45 +00:00
|
|
|
Insert(0, "123", 0),
|
|
|
|
Insert(0, "456", 0),
|
|
|
|
Undo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123\n"}]"#),
|
|
|
|
Undo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
|
|
|
];
|
|
|
|
OpTester::new().run_script(ops);
|
|
|
|
}
|
2021-08-06 14:25:09 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn delta_redo_insert() {
|
|
|
|
let ops = vec![
|
2021-08-06 15:06:27 +00:00
|
|
|
Insert(0, "\n", 0),
|
2021-08-06 14:25:09 +00:00
|
|
|
Insert(0, "123", 0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123\n"}]"#),
|
|
|
|
Undo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
|
|
|
Redo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123\n"}]"#),
|
|
|
|
];
|
|
|
|
OpTester::new().run_script(ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn delta_redo_insert2() {
|
|
|
|
let ops = vec![
|
2021-08-06 15:06:27 +00:00
|
|
|
Insert(0, "\n", 0),
|
2021-08-06 14:25:09 +00:00
|
|
|
Insert(0, "123", 0),
|
|
|
|
Insert(0, "456", 3),
|
|
|
|
AssertStr(0, "123456\n"),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123456\n"}]"#),
|
|
|
|
Undo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123\n"}]"#),
|
|
|
|
Redo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123456\n"}]"#),
|
|
|
|
Undo(0),
|
|
|
|
AssertOpsJson(0, r#"[{"insert":"123\n"}]"#),
|
|
|
|
];
|
|
|
|
OpTester::new().run_script(ops);
|
|
|
|
}
|