| 74 | * @param {t.TestCase} _tc |
| 75 | */ |
| 76 | export 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 | |
| 91 | export const testYdocDiff = () => { |
| 92 | const ydocStart = new Y.Doc() |