From d5602190e3335585dba1037759147cfa074d4c4d Mon Sep 17 00:00:00 2001 From: Ernest Date: Wed, 3 May 2023 13:11:47 -0700 Subject: [PATCH] test case --- tests/y-text.tests.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 87ac21a4..2f151066 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -1673,6 +1673,29 @@ export const testDeltaAfterConcurrentFormatting = tc => { t.compare(deltas, [[{ retain: 3, attributes: { bold: true } }, { retain: 2, attributes: { bold: null } }]]) } +/** + * @param {t.TestCase} tc + */ +export const testDeltaAfterDelete = tc => { + const { text0, text1, testConnector } = init(tc, { users: 2 }) + text0.insert(0, 'abc', {bold: true}); + text0.insertEmbed(3, new Y.Map([['key', 'val']])); + testConnector.flushAllMessages() + /** + * @type {any} + */ + const deltas = [] + text1.observe(event => { + if (event.delta.length > 0) { + deltas.push(event.delta) + } + }) + text0.delete(0, 3); + testConnector.flushAllMessages() + console.error("The actual deltas", deltas); + t.compare(deltas, [[{ delete: 3}]]) +} + /** * @param {t.TestCase} tc */