add example to createDocFromSnapshot - #159

This commit is contained in:
Kevin Jahns
2023-04-27 18:08:10 +02:00
parent 1f2f08ef7e
commit adaa95ebb8
2 changed files with 21 additions and 1 deletions

View File

@@ -2,6 +2,18 @@ import * as Y from '../src/index.js'
import * as t from 'lib0/testing'
import { init } from './testHelper.js'
/**
* @param {t.TestCase} tc
*/
export const testBasic = tc => {
const ydoc = new Y.Doc({ gc: false })
ydoc.getText().insert(0, 'world!')
const snapshot = Y.snapshot(ydoc)
ydoc.getText().insert(0, 'hello ')
const restored = Y.createDocFromSnapshot(ydoc, snapshot)
t.assert(restored.getText().toString() === 'world!')
}
/**
* @param {t.TestCase} tc
*/