| 331 | * @param {t.TestCase} tc |
| 332 | */ |
| 333 | export 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 |