fix type errors in tests
This commit is contained in:
parent
c9995bda17
commit
8c1d7c72b8
@ -114,6 +114,7 @@ export const testSubdoc = _tc => {
|
|||||||
doc.on('subdocs', subdocs => {
|
doc.on('subdocs', subdocs => {
|
||||||
event = [Array.from(subdocs.added).map(x => x.guid), Array.from(subdocs.removed).map(x => x.guid), Array.from(subdocs.loaded).map(x => x.guid)]
|
event = [Array.from(subdocs.added).map(x => x.guid), Array.from(subdocs.removed).map(x => x.guid), Array.from(subdocs.loaded).map(x => x.guid)]
|
||||||
})
|
})
|
||||||
|
/** @type {Y.Map<{ a: Y.Doc; b: Y.Doc, c: Y.Doc; }>} */
|
||||||
const subdocs = doc.getMap('mysubdocs')
|
const subdocs = doc.getMap('mysubdocs')
|
||||||
const docA = new Y.Doc({ guid: 'a' })
|
const docA = new Y.Doc({ guid: 'a' })
|
||||||
docA.load()
|
docA.load()
|
||||||
@ -121,18 +122,18 @@ export const testSubdoc = _tc => {
|
|||||||
t.compare(event, [['a'], [], ['a']])
|
t.compare(event, [['a'], [], ['a']])
|
||||||
|
|
||||||
event = null
|
event = null
|
||||||
subdocs.get('a').load()
|
subdocs.get('a')?.load()
|
||||||
t.assert(event === null)
|
t.assert(event === null)
|
||||||
|
|
||||||
event = null
|
event = null
|
||||||
subdocs.get('a').destroy()
|
subdocs.get('a')?.destroy()
|
||||||
t.compare(event, [['a'], ['a'], []])
|
t.compare(event, [['a'], ['a'], []])
|
||||||
subdocs.get('a').load()
|
subdocs.get('a')?.load()
|
||||||
t.compare(event, [[], [], ['a']])
|
t.compare(event, [[], [], ['a']])
|
||||||
|
|
||||||
subdocs.set('b', new Y.Doc({ guid: 'a', shouldLoad: false }))
|
subdocs.set('b', new Y.Doc({ guid: 'a', shouldLoad: false }))
|
||||||
t.compare(event, [['a'], [], []])
|
t.compare(event, [['a'], [], []])
|
||||||
subdocs.get('b').load()
|
subdocs.get('b')?.load()
|
||||||
t.compare(event, [[], [], ['a']])
|
t.compare(event, [[], [], ['a']])
|
||||||
|
|
||||||
const docC = new Y.Doc({ guid: 'c' })
|
const docC = new Y.Doc({ guid: 'c' })
|
||||||
@ -156,7 +157,9 @@ export const testSubdoc = _tc => {
|
|||||||
Y.applyUpdate(doc2, Y.encodeStateAsUpdate(doc))
|
Y.applyUpdate(doc2, Y.encodeStateAsUpdate(doc))
|
||||||
t.compare(event, [['a', 'a', 'c'], [], []])
|
t.compare(event, [['a', 'a', 'c'], [], []])
|
||||||
|
|
||||||
doc2.getMap('mysubdocs').get('a').load()
|
/** @type {Y.Map<Record<string, Y.Doc>>} */
|
||||||
|
const mysubdocs = doc2.getMap('mysubdocs')
|
||||||
|
mysubdocs.get('a')?.load()
|
||||||
t.compare(event, [[], [], ['a']])
|
t.compare(event, [[], [], ['a']])
|
||||||
|
|
||||||
t.compare(Array.from(doc2.getSubdocGuids()), ['a', 'c'])
|
t.compare(Array.from(doc2.getSubdocGuids()), ['a', 'c'])
|
||||||
|
@ -448,6 +448,7 @@ export const testUndoNestedUndoIssue = _tc => {
|
|||||||
*/
|
*/
|
||||||
export const testConsecutiveRedoBug = _tc => {
|
export const testConsecutiveRedoBug = _tc => {
|
||||||
const doc = new Y.Doc()
|
const doc = new Y.Doc()
|
||||||
|
/** @type {Y.Map<Record<string, Y.Map<any>>>} */
|
||||||
const yRoot = doc.getMap()
|
const yRoot = doc.getMap()
|
||||||
const undoMgr = new Y.UndoManager(yRoot)
|
const undoMgr = new Y.UndoManager(yRoot)
|
||||||
|
|
||||||
@ -481,7 +482,7 @@ export const testConsecutiveRedoBug = _tc => {
|
|||||||
t.compare(yRoot.get('a'), undefined)
|
t.compare(yRoot.get('a'), undefined)
|
||||||
|
|
||||||
undoMgr.redo() // x=0, y=0
|
undoMgr.redo() // x=0, y=0
|
||||||
yPoint = yRoot.get('a')
|
yPoint = yRoot.get('a') || new Y.Map()
|
||||||
|
|
||||||
t.compare(yPoint.toJSON(), { x: 0, y: 0 })
|
t.compare(yPoint.toJSON(), { x: 0, y: 0 })
|
||||||
undoMgr.redo() // x=100, y=100
|
undoMgr.redo() // x=100, y=100
|
||||||
|
Loading…
x
Reference in New Issue
Block a user