MCPcopy
hub / github.com/yjs/yjs / testRepeatRandomIntersects

Function testRepeatRandomIntersects

tests/IdMap.tests.js:169–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167 * @param {t.TestCase} tc
168 */
169export const testRepeatRandomIntersects = tc => {
170 const clients = 4
171 const clockRange = 100
172 const ids1 = createRandomIdMap(tc.prng, clients, clockRange, [1])
173 const ids2 = createRandomIdMap(tc.prng, clients, clockRange, ['two'])
174 const intersected = idmap.intersectMaps(ids1, ids2)
175 for (let client = 0; client < clients; client++) {
176 for (let clock = 0; clock < clockRange; clock++) {
177 t.assert((ids1.has(client, clock) && ids2.has(client, clock)) === intersected.has(client, clock))
178 /**
179 * @type {Array<any>?}
180 */
181 const slice1 = ids1.slice(client, clock, 1)[0].attrs
182 /**
183 * @type {Array<any>?}
184 */
185 const slice2 = ids2.slice(client, clock, 1)[0].attrs
186 /**
187 * @type {Array<any>?}
188 */
189 const expectedAttrs = (slice1 != null && slice2 != null) ? slice1.concat(slice2) : null
190 const attrs = intersected.slice(client, clock, 1)[0].attrs
191 t.assert(attrs?.length === expectedAttrs?.length)
192 }
193 }
194 const diffed1 = idmap.diffIdMap(ids1, ids2)
195 const altDiffed1 = idmap.diffIdMap(ids1, intersected)
196 compareIdMaps(diffed1, altDiffed1)
197}
198
199/**
200 * @param {t.TestCase} tc

Callers

nothing calls this directly

Calls 3

createRandomIdMapFunction · 0.90
hasMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…