MCPcopy
hub / github.com/yjs/yjs / testChangeEvent

Function testChangeEvent

tests/y-array.tests.js:333–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331 * @param {t.TestCase} tc
332 */
333export const testChangeEvent = tc => {
334 const { array0, users } = init(tc, { users: 2 })
335 /**
336 * @type {delta.Delta<any>}
337 */
338 let d = delta.create()
339 array0.observe(e => {
340 d = e.delta
341 })
342 const newArr = new Y.Type()
343 array0.insert(0, [newArr, 4, 'dtrn'])
344 t.assert(d !== null && d.children.len === 1)
345 t.compare(d, delta.create().insert([newArr, 4, 'dtrn']))
346 array0.delete(0, 2)
347 t.assert(d !== null && d.children.len === 1)
348 t.compare(d.toJSON().children, [{ delete: 2 }])
349 array0.insert(1, [0.1])
350 t.assert(d !== null && d.children.len === 2)
351 t.compare(d, delta.create().retain(1).insert([0.1]).done())
352 compare(users)
353}
354
355/**
356 * @param {t.TestCase} tc

Callers

nothing calls this directly

Calls 6

initFunction · 0.90
compareFunction · 0.90
observeMethod · 0.80
insertMethod · 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…