From e1fd2de7b8d4a32c8d52d3e8a7d30b74c9bb13df Mon Sep 17 00:00:00 2001 From: Ernest Date: Wed, 3 May 2023 13:19:10 -0700 Subject: [PATCH] adding tests --- tests/y-text.tests.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 2f151066..29c467c1 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -1674,6 +1674,11 @@ export const testDeltaAfterConcurrentFormatting = tc => { } /** + * Check if the delta is correct after a delete operation. Specifically, we want to make sure that + * an embed following the deleted text does not get an attribute update. + * + * See https://github.com/yjs/yjs/issues/529 + * * @param {t.TestCase} tc */ export const testDeltaAfterDelete = tc => { @@ -1692,7 +1697,28 @@ export const testDeltaAfterDelete = tc => { }) text0.delete(0, 3); testConnector.flushAllMessages() - console.error("The actual deltas", deltas); + t.compare(deltas, [[{ delete: 3}]]) +} + +/** + * @param {t.TestCase} tc + */ +export const testDeltaAfterDeleteWithText = tc => { + const { text0, text1, testConnector } = init(tc, { users: 2 }) + text0.insert(0, 'abc', {bold: true}); + text0.insert(3, 'def'); + testConnector.flushAllMessages() + /** + * @type {any} + */ + const deltas = [] + text1.observe(event => { + if (event.delta.length > 0) { + deltas.push(event.delta) + } + }) + text0.delete(0, 3); + testConnector.flushAllMessages() t.compare(deltas, [[{ delete: 3}]]) }