Expose to JS

This commit is contained in:
Andras Schmelczer 2025-10-26 21:44:43 +00:00
parent 450eaaff05
commit 1b46e5d237
9 changed files with 95 additions and 17 deletions

View file

@ -46,12 +46,11 @@ fn test_document_one_way_with_cursors_and_serialisation() {
&*BuiltinTokenizer::Word,
);
let serialised_left = serde_yaml::from_str(
&serde_yaml::to_string(&left_operations.serialise_as_change_set()).unwrap(),
)
.unwrap();
let serialised_left =
serde_yaml::from_str(&serde_yaml::to_string(&left_operations.to_change_set()).unwrap())
.unwrap();
let serialised_right = serde_yaml::from_str(
&serde_yaml::to_string(&right_operations.serialise_as_change_set()).unwrap(),
&serde_yaml::to_string(&right_operations.to_change_set()).unwrap(),
)
.unwrap();

View file

@ -46,7 +46,7 @@ fn test_merge_text_with_cursors() {
}
#[wasm_bindgen_test(unsupported = test)]
fn merge_binary() {
fn test_merge_binary() {
let left = [0, 1, 2];
let right = [3, 4, 5];
assert_eq!(
@ -62,6 +62,14 @@ fn test_is_binary() {
assert!(!is_binary(b"hello"));
}
#[wasm_bindgen_test(unsupported = test)]
fn test_get_compact_diff() {
let parent = "hello ";
let changed = "world";
let result = get_compact_diff(parent, &changed.into(), BuiltinTokenizer::Word);
assert_eq!(result, "{\"operations\":[-6,\"world\"],\"cursors\":[]}");
}
#[wasm_bindgen_test(unsupported = test)]
fn test_is_binary_empty() {
assert!(!is_binary(b""));