automerge/javascript/test/extra_api_tests.ts
Alex Good 6c0d102032
automerge-js: Add backwards compatibility text layer
The new text features are faster and more ergonomic but not backwards
compatible. In order to make them backwards compatible re-expose the
original functionality and move the new API under a `future` export.
This allows users to interoperably use both implementations.
2023-01-10 12:52:21 +00:00

28 lines
924 B
TypeScript

import * as assert from "assert"
import { unstable as Automerge } from "../src"
describe("Automerge", () => {
describe("basics", () => {
it("should allow you to load incrementally", () => {
let doc1 = Automerge.from<any>({ foo: "bar" })
let doc2 = Automerge.init<any>()
doc2 = Automerge.loadIncremental(doc2, Automerge.save(doc1))
doc1 = Automerge.change(doc1, d => (d.foo2 = "bar2"))
doc2 = Automerge.loadIncremental(
doc2,
Automerge.getBackend(doc1).saveIncremental()
)
doc1 = Automerge.change(doc1, d => (d.foo = "bar2"))
doc2 = Automerge.loadIncremental(
doc2,
Automerge.getBackend(doc1).saveIncremental()
)
doc1 = Automerge.change(doc1, d => (d.x = "y"))
doc2 = Automerge.loadIncremental(
doc2,
Automerge.getBackend(doc1).saveIncremental()
)
assert.deepEqual(doc1, doc2)
})
})
})