add loading event logic

This commit is contained in:
Kevin Jahns
2021-11-24 23:15:55 +01:00
parent e90d9de5ed
commit 28e1b19e57
2 changed files with 24 additions and 0 deletions

View File

@@ -228,3 +228,19 @@ export const testSubdocsUndo = tc => {
undoManager.redo()
t.assert(elems.length === 1)
}
/**
* @param {t.TestCase} tc
*/
export const testLoadDocs = async tc => {
const ydoc = new Y.Doc()
t.assert(ydoc.isLoaded === false)
let loadedEvent = false
ydoc.on('load', () => {
loadedEvent = true
})
ydoc.emit('load', [ydoc])
await ydoc.whenLoaded
t.assert(loadedEvent)
t.assert(ydoc.isLoaded)
}