Make JS API usable

This commit is contained in:
Andras Schmelczer 2025-04-02 21:07:33 +01:00
parent 565372b526
commit 40323c33ee
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
3 changed files with 54 additions and 55 deletions

View file

@ -1,6 +1,6 @@
use insta::assert_debug_snapshot;
use sync_lib::{
cursor::{OwnedCursorPosition, OwnedTextWithCursors},
cursor::{CursorPosition, TextWithCursors},
*,
};
use wasm_bindgen_test::*;
@ -50,36 +50,18 @@ fn test_merge_text() {
fn test_merge_text_with_cursors() {
let result = merge_text_with_cursors(
"hi",
OwnedTextWithCursors::new("hi world", vec![]),
OwnedTextWithCursors::new(
"hi",
vec![
OwnedCursorPosition {
id: 0,
char_index: 1,
},
OwnedCursorPosition {
id: 1,
char_index: 2,
},
],
TextWithCursors::new("hi world".to_owned(), vec![]),
TextWithCursors::new(
"hi".to_owned(),
vec![CursorPosition::new(0, 1), CursorPosition::new(1, 2)],
),
);
assert_eq!(
result,
OwnedTextWithCursors::new(
"hi world",
vec![
OwnedCursorPosition {
id: 0,
char_index: 1,
},
OwnedCursorPosition {
id: 1,
char_index: 2,
}
]
TextWithCursors::new(
"hi world".to_owned(),
vec![CursorPosition::new(0, 1), CursorPosition::new(1, 2)]
),
);
}