mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 21:07:43 +00:00
test: add import via frontiers test
This commit is contained in:
parent
b940214985
commit
826e7fdcb3
1 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { ContainerID, Loro, LoroList, LoroMap, setPanicHook } from "../src";
|
||||
import { ContainerID, Loro, LoroList, LoroMap, setPanicHook, toEncodedVersion } from "../src";
|
||||
|
||||
setPanicHook();
|
||||
|
||||
|
@ -130,6 +130,18 @@ describe("import", () => {
|
|||
expect(a.getText("text").toString()).toBe("abc");
|
||||
});
|
||||
|
||||
it("import by frontiers", () => {
|
||||
const a = new Loro();
|
||||
a.getText("text").insert(0, "a");
|
||||
const b = new Loro();
|
||||
b.import(a.exportFrom());
|
||||
b.getText("text").insert(1, "b");
|
||||
b.getList("list").insert(0, [1, 2]);
|
||||
const updates = b.exportFrom(toEncodedVersion(b.frontiersToVV(a.frontiers())));
|
||||
a.import(updates);
|
||||
expect(a.toJson()).toStrictEqual(b.toJson());
|
||||
});
|
||||
|
||||
it("from snapshot", () => {
|
||||
const a = new Loro();
|
||||
a.getText("text").insert(0, "hello");
|
||||
|
|
Loading…
Reference in a new issue