mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
74 lines
1.7 KiB
Rust
74 lines
1.7 KiB
Rust
pub mod helper;
|
|
|
|
use crate::helper::{TestOp::*, *};
|
|
use flowy_ot::core::Interval;
|
|
|
|
#[test]
|
|
fn delta_undo_insert() {
|
|
let ops = vec![
|
|
Insert(0, "\n", 0),
|
|
Insert(0, "123", 0),
|
|
Undo(0),
|
|
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
|
];
|
|
OpTester::new().run_script(ops);
|
|
}
|
|
|
|
#[test]
|
|
fn delta_undo_insert2() {
|
|
let ops = vec![
|
|
Insert(0, "\n", 0),
|
|
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);
|
|
}
|
|
|
|
#[test]
|
|
fn delta_redo_insert() {
|
|
let ops = vec![
|
|
Insert(0, "\n", 0),
|
|
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![
|
|
Insert(0, "\n", 0),
|
|
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);
|
|
}
|
|
|
|
#[test]
|
|
fn delta_undo_attributes() {
|
|
let ops = vec![
|
|
Insert(0, "\n", 0),
|
|
Insert(0, "123", 0),
|
|
Bold(0, Interval::new(0, 3), true),
|
|
Undo(0),
|
|
AssertOpsJson(0, r#"[{"insert":"123\n"}]"#),
|
|
];
|
|
OpTester::new().run_script(ops);
|
|
}
|