fix array iterator on merged content. fixes #152
This commit is contained in:
parent
668e9e8a9b
commit
ef6c382e20
@ -287,16 +287,13 @@ export const typeListCreateIterator = type => {
|
|||||||
while (n !== null && n.deleted) {
|
while (n !== null && n.deleted) {
|
||||||
n = n.right
|
n = n.right
|
||||||
}
|
}
|
||||||
}
|
// check if we reached the end, no need to check currentContent, because it does not exist
|
||||||
// check if we reached the end, no need to check currentContent, because it does not exist
|
if (n === null) {
|
||||||
if (n === null) {
|
return {
|
||||||
return {
|
done: true,
|
||||||
done: true,
|
value: undefined
|
||||||
value: undefined
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// currentContent could exist from the last iteration
|
|
||||||
if (currentContent === null) {
|
|
||||||
// we found n, so we can set currentContent
|
// we found n, so we can set currentContent
|
||||||
currentContent = n.getContent()
|
currentContent = n.getContent()
|
||||||
currentContentIndex = 0
|
currentContentIndex = 0
|
||||||
|
@ -265,6 +265,18 @@ export const compare = users => {
|
|||||||
t.assert(u.store.pendingStack.length === 0)
|
t.assert(u.store.pendingStack.length === 0)
|
||||||
t.assert(u.store.pendingClientsStructRefs.size === 0)
|
t.assert(u.store.pendingClientsStructRefs.size === 0)
|
||||||
}
|
}
|
||||||
|
// Test Array iterator
|
||||||
|
t.compare(userArrayValues[0], Array.from(users[0].getArray('array')).map(v => JSON.stringify(v)))
|
||||||
|
// Test Map iterator
|
||||||
|
/**
|
||||||
|
* @type {Object<string,any>}
|
||||||
|
*/
|
||||||
|
const mapRes = {}
|
||||||
|
for (let [k, v] of users[0].getMap('map')) {
|
||||||
|
mapRes[k] = v instanceof Y.AbstractType ? v.toJSON() : v
|
||||||
|
}
|
||||||
|
t.compare(userMapValues[0], mapRes)
|
||||||
|
// Compare all users
|
||||||
for (let i = 0; i < users.length - 1; i++) {
|
for (let i = 0; i < users.length - 1; i++) {
|
||||||
t.compare(userArrayValues[i].length, users[i].getArray('array').length)
|
t.compare(userArrayValues[i].length, users[i].getArray('array').length)
|
||||||
t.compare(userArrayValues[i], userArrayValues[i + 1])
|
t.compare(userArrayValues[i], userArrayValues[i + 1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user