MCPcopy
hub / github.com/yjs/yjs / testAttributedEvents

Function testAttributedEvents

tests/attribution.tests.js:34–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 * @param {t.TestCase} _tc
33 */
34export const testAttributedEvents = _tc => {
35 const ydoc = new Y.Doc()
36 const ytext = ydoc.get()
37 ytext.insert(0, 'hello world')
38 const v1 = Y.cloneDoc(ydoc)
39 ydoc.transact(() => {
40 ytext.delete(6, 5)
41 })
42 const am = Y.createAttributionManagerFromDiff(v1, ydoc)
43 const c1 = ytext.toDelta(am)
44 t.compare(c1, delta.create().insert('hello ').insert('world', null, { delete: [] }))
45 let calledObserver = false
46 ytext.observe(event => {
47 const d = event.getDelta(am)
48 t.compare(d, delta.create().retain(11).insert('!', null, { insert: [] }))
49 calledObserver = true
50 })
51 ytext.applyDelta(delta.create().retain(11).insert('!'), am)
52 t.assert(calledObserver)
53}
54
55/**
56 * @param {t.TestCase} _tc

Callers

nothing calls this directly

Calls 8

getMethod · 0.95
transactMethod · 0.95
insertMethod · 0.80
toDeltaMethod · 0.80
observeMethod · 0.80
getDeltaMethod · 0.80
applyDeltaMethod · 0.80
deleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…