MCPcopy
hub / github.com/yjs/yjs / testAttributedContent

Function testAttributedContent

tests/y-array.tests.js:463–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461 * @param {t.TestCase} _tc
462 */
463export const testAttributedContent = _tc => {
464 const ydoc = new Y.Doc({ gc: false })
465 /**
466 * @type {Y.Type<{ children: number }>}
467 */
468 const yarray = ydoc.get()
469 yarray.insert(0, [1, 2])
470 let attributionManager = Y.noAttributionsManager
471
472 ydoc.on('afterTransaction', tr => {
473 // attributionManager = new TwosetAttributionManager(createIdMapFromIdSet(tr.insertSet, [new Y.Attribution('insertedAt', 42), new Y.Attribution('insert', 'kevin')]), createIdMapFromIdSet(tr.deleteSet, [new Y.Attribution('delete', 'kevin')]))
474 attributionManager = new Y.TwosetAttributionManager(Y.createIdMapFromIdSet(tr.insertSet, []), Y.createIdMapFromIdSet(tr.deleteSet, []))
475 })
476 t.group('insert / delete', () => {
477 ydoc.transact(() => {
478 yarray.delete(0, 1)
479 yarray.insert(1, [42])
480 })
481 const expectedContent = delta.create().insert([1], null, { delete: [] }).insert([2]).insert([42], null, { insert: [] })
482 const attributedContent = yarray.toDelta(attributionManager)
483 console.log(attributedContent.toJSON())
484 t.assert(attributedContent.equals(expectedContent))
485 })
486}
487
488let _uniqueNumber = 0
489const getUniqueNumber = () => _uniqueNumber++

Callers

nothing calls this directly

Calls 6

getMethod · 0.95
transactMethod · 0.95
insertMethod · 0.80
toDeltaMethod · 0.80
deleteMethod · 0.45
toJSONMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…