From c2e70764004d6e485da41fa8ca8a384c541a3de1 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Mon, 20 Nov 2023 12:53:58 +0100 Subject: [PATCH] add iterator type checks --- tests/y-map.tests.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/y-map.tests.js b/tests/y-map.tests.js index 346bd746..70b3e3b1 100644 --- a/tests/y-map.tests.js +++ b/tests/y-map.tests.js @@ -8,6 +8,31 @@ import * as Y from '../src/index.js' import * as t from 'lib0/testing' import * as prng from 'lib0/prng' +/** + * @param {t.TestCase} _tc + */ +export const testIterators = _tc => { + const ydoc = new Y.Doc() + /** + * @type {Y.Map} + */ + const ymap = ydoc.getMap() + // we are only checking if the type assumptions are correct + /** + * @type {Array} + */ + const vals = Array.from(ymap.values()) + /** + * @type {Array<[string,number]>} + */ + const entries = Array.from(ymap.entries()) + /** + * @type {Array} + */ + const keys = Array.from(ymap.keys()) + console.log(vals, entries, keys) +} + /** * Computing event changes after transaction should result in an error. See yjs#539 *