diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 62964520..3bd88365 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -78,6 +78,29 @@ export const testBasicFormat = tc => { compare(users) } +/** + * @param {t.TestCase} tc + */ +export const testMultilineFormat = tc => { + const ydoc = new Y.Doc() + const testText = ydoc.getText('test') + testText.insert(0, 'Test\nMulti-line\nFormatting') + testText.applyDelta([ + { retain: 4, attributes: { bold: true } }, + { retain: 1 }, // newline character + { retain: 10, attributes: { bold: true } }, + { retain: 1 }, // newline character + { retain: 10, attributes: { bold: true } } + ]) + t.compare(testText.toDelta(), [ + { insert: 'Test', attributes: { bold: true } }, + { insert: '\n' }, + { insert: 'Multi-line', attributes: { bold: true } }, + { insert: '\n' }, + { insert: 'Formatting', attributes: { bold: true } } + ]) +} + /** * @param {t.TestCase} tc */ @@ -286,7 +309,9 @@ export const testBestCase = tc => { } const tryGc = () => { + // @ts-ignore if (typeof global !== 'undefined' && global.gc) { + // @ts-ignore global.gc() } }