mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 12:25:03 +00:00
fix: from snapshot should enable auto commit
This commit is contained in:
parent
089d05e3a0
commit
b940214985
2 changed files with 11 additions and 1 deletions
|
@ -238,7 +238,8 @@ impl Loro {
|
||||||
///
|
///
|
||||||
#[wasm_bindgen(js_name = "fromSnapshot")]
|
#[wasm_bindgen(js_name = "fromSnapshot")]
|
||||||
pub fn from_snapshot(snapshot: &[u8]) -> JsResult<Loro> {
|
pub fn from_snapshot(snapshot: &[u8]) -> JsResult<Loro> {
|
||||||
let doc = LoroDoc::from_snapshot(snapshot)?;
|
let mut doc = LoroDoc::from_snapshot(snapshot)?;
|
||||||
|
doc.start_auto_commit();
|
||||||
Ok(Loro(doc))
|
Ok(Loro(doc))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,15 @@ describe("import", () => {
|
||||||
a.import(b.exportFrom(a.version()));
|
a.import(b.exportFrom(a.version()));
|
||||||
expect(a.getText("text").toString()).toBe("abc");
|
expect(a.getText("text").toString()).toBe("abc");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("from snapshot", () => {
|
||||||
|
const a = new Loro();
|
||||||
|
a.getText("text").insert(0, "hello");
|
||||||
|
const bytes = a.exportSnapshot();
|
||||||
|
const b = Loro.fromSnapshot(bytes);
|
||||||
|
b.getText("text").insert(0, "123");
|
||||||
|
expect(b.toJson()).toStrictEqual({ "text": "123hello" })
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("map", () => {
|
describe("map", () => {
|
||||||
|
|
Loading…
Reference in a new issue