MCPcopy
hub / github.com/yjs/yjs / testInsertionsIntoAttributedContent

Function testInsertionsIntoAttributedContent

tests/attribution.tests.js:76–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 * @param {t.TestCase} _tc
75 */
76export const testInsertionsIntoAttributedContent = _tc => {
77 const ydoc = new Y.Doc()
78 const ytext = ydoc.get()
79 ytext.insert(0, 'hello ')
80 const v1 = Y.cloneDoc(ydoc)
81 ydoc.transact(() => {
82 ytext.insert(6, 'word')
83 })
84 const am = Y.createAttributionManagerFromDiff(v1, ydoc)
85 const c1 = ytext.toDelta(am)
86 t.compare(c1, delta.create().insert('hello ').insert('word', null, { insert: [] }))
87 ytext.applyDelta(delta.create().retain(9).insert('l'), am)
88 t.assert(ytext.toString() === 'hello world')
89}
90
91export const testYdocDiff = () => {
92 const ydocStart = new Y.Doc()

Callers

nothing calls this directly

Calls 6

getMethod · 0.95
transactMethod · 0.95
insertMethod · 0.80
toDeltaMethod · 0.80
applyDeltaMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…