From 610e5328686aac560a3298e1c35ee758a7c10f00 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 27 Nov 2021 11:37:11 +0100 Subject: [PATCH] add test case for nested Y.Text as embeds. --- tests/undo-redo.tests.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/undo-redo.tests.js b/tests/undo-redo.tests.js index 249a3505..991225ca 100644 --- a/tests/undo-redo.tests.js +++ b/tests/undo-redo.tests.js @@ -248,6 +248,26 @@ export const testTypeScope = tc => { t.assert(text1.toString() === '') } +/** + * @param {t.TestCase} tc + */ +export const testUndoInEmbed = tc => { + const { text0 } = init(tc, { users: 3 }) + const undoManager = new Y.UndoManager(text0) + const nestedText = new Y.Text('initial text') + undoManager.stopCapturing() + text0.insertEmbed(0, nestedText, { bold: true }) + t.assert(nestedText.toString() === 'initial text') + undoManager.stopCapturing() + nestedText.delete(0, nestedText.length) + nestedText.insert(0, 'other text') + t.assert(nestedText.toString() === 'other text') + undoManager.undo() + t.assert(nestedText.toString() === 'initial text') + undoManager.undo() + t.assert(text0.length === 0) +} + /** * @param {t.TestCase} tc */