diff --git a/src/types/AbstractType.js b/src/types/AbstractType.js index c1ffc18f..d16ca9dd 100644 --- a/src/types/AbstractType.js +++ b/src/types/AbstractType.js @@ -287,16 +287,13 @@ export const typeListCreateIterator = type => { while (n !== null && n.deleted) { n = n.right } - } - // check if we reached the end, no need to check currentContent, because it does not exist - if (n === null) { - return { - done: true, - value: undefined + // check if we reached the end, no need to check currentContent, because it does not exist + if (n === null) { + return { + done: true, + value: undefined + } } - } - // currentContent could exist from the last iteration - if (currentContent === null) { // we found n, so we can set currentContent currentContent = n.getContent() currentContentIndex = 0 diff --git a/tests/testHelper.js b/tests/testHelper.js index bf83e5b1..62c3e9c8 100644 --- a/tests/testHelper.js +++ b/tests/testHelper.js @@ -265,6 +265,18 @@ export const compare = users => { t.assert(u.store.pendingStack.length === 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} + */ + 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++) { t.compare(userArrayValues[i].length, users[i].getArray('array').length) t.compare(userArrayValues[i], userArrayValues[i + 1])