Fix tests
This commit is contained in:
parent
8e1690a0bf
commit
20eb81a78d
3 changed files with 9 additions and 6 deletions
|
|
@ -1,8 +1,10 @@
|
|||
mod diff_error;
|
||||
mod edited_text;
|
||||
mod operation;
|
||||
mod utils;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub use diff_error::DiffError;
|
||||
pub use edited_text::EditedText;
|
||||
pub use operation::Operation;
|
||||
|
||||
|
|
|
|||
|
|
@ -105,16 +105,17 @@ pub fn diff(parent: &str, changed: &TextWithCursors, tokenizer: BuiltinTokenizer
|
|||
pub fn undiff(parent: &str, diff: Vec<JsValue>, tokenizer: BuiltinTokenizer) -> String {
|
||||
set_panic_hook();
|
||||
|
||||
EditedText::from_diff(
|
||||
match EditedText::from_diff(
|
||||
parent,
|
||||
diff.into_iter()
|
||||
.map(std::convert::TryInto::try_into)
|
||||
.collect::<Result<_, _>>()
|
||||
.expect("Invalid diff format"),
|
||||
&*tokenizer,
|
||||
)
|
||||
.apply()
|
||||
.text()
|
||||
) {
|
||||
Ok(edited_text) => edited_text.apply().text(),
|
||||
Err(e) => panic!("{}", e),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_panic_hook() {
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ fn test_document_one_way_with_serialisation() {
|
|||
.unwrap();
|
||||
|
||||
let restored_left_operations =
|
||||
EditedText::from_diff(&parent, serialised_left, &*BuiltinTokenizer::Word);
|
||||
EditedText::from_diff(&parent, serialised_left, &*BuiltinTokenizer::Word).unwrap();
|
||||
let restored_right_operations =
|
||||
EditedText::from_diff(&parent, serialised_right, &*BuiltinTokenizer::Word);
|
||||
EditedText::from_diff(&parent, serialised_right, &*BuiltinTokenizer::Word).unwrap();
|
||||
|
||||
doc.assert_eq_without_cursors(
|
||||
&restored_left_operations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue