2 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
8 import {AutoLinkNode, LinkNode} from '@lexical/link';
9 import {ListItemNode, ListNode} from '@lexical/list';
10 import {HeadingNode, QuoteNode, registerRichText} from '@lexical/rich-text';
14 } from '@lexical/selection/__tests__/utils';
15 import {TableCellNode, TableNode, TableRowNode} from '@lexical/table';
16 import {$createParagraphNode, $insertNodes, LexicalEditor} from 'lexical';
17 import {createTestEditor, initializeClipboard} from 'lexical/__tests__/utils';
19 jest.mock('lexical/shared/environment', () => {
20 const originalModule = jest.requireActual('lexical/shared/environment');
21 return {...originalModule, IS_FIREFOX: true};
24 Range.prototype.getBoundingClientRect = function (): DOMRect {
43 initializeClipboard();
45 Range.prototype.getBoundingClientRect = function (): DOMRect {
64 describe('LexicalEventHelpers', () => {
65 let container: HTMLDivElement | null = null;
67 beforeEach(async () => {
68 container = document.createElement('div');
69 document.body.appendChild(container);
74 document.body.removeChild(container!);
78 let editor: LexicalEditor | null = null;
80 async function init() {
97 h1: 'editor-heading-h1',
98 h2: 'editor-heading-h2',
99 h3: 'editor-heading-h3',
100 h4: 'editor-heading-h4',
101 h5: 'editor-heading-h5',
102 h6: 'editor-heading-h6',
104 image: 'editor-image',
106 listitem: 'editor-listitem',
107 olDepth: ['editor-list-ol'],
108 ulDepth: ['editor-list-ul'],
110 paragraph: 'editor-paragraph',
111 placeholder: 'editor-placeholder',
112 quote: 'editor-quote',
114 bold: 'editor-text-bold',
115 code: 'editor-text-code',
116 hashtag: 'editor-text-hashtag',
117 italic: 'editor-text-italic',
118 link: 'editor-text-link',
119 strikethrough: 'editor-text-strikethrough',
120 underline: 'editor-text-underline',
121 underlineStrikethrough: 'editor-text-underlineStrikethrough',
126 editor = createTestEditor(config);
127 registerRichText(editor);
129 const root = document.createElement('div');
130 root.setAttribute('contenteditable', 'true');
131 container?.append(root);
133 editor.setRootElement(root);
135 editor.update(() => {
136 $insertNodes([$createParagraphNode()])
138 editor.commitUpdates();
141 async function update(fn: () => void) {
142 await editor!.update(fn);
143 editor?.commitUpdates();
145 return Promise.resolve().then();
148 test('Expect initial output to be a block with no text', () => {
149 expect(container!.innerHTML).toBe(
150 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><br></p></div>',
154 describe('onPasteForRichText', () => {
155 describe('baseline', () => {
159 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><h1 class="editor-heading-h1"><span data-lexical-text="true">Hello</span></h1></div>',
160 inputs: [pasteHTML(`<meta charset='utf-8'><h1>Hello</h1>`)],
161 name: 'should produce the correct editor state from a pasted HTML h1 element',
165 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><h2 class="editor-heading-h2"><span data-lexical-text="true">From</span></h2></div>',
166 inputs: [pasteHTML(`<meta charset='utf-8'><h2>From</h2>`)],
167 name: 'should produce the correct editor state from a pasted HTML h2 element',
171 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><h3 class="editor-heading-h3"><span data-lexical-text="true">The</span></h3></div>',
172 inputs: [pasteHTML(`<meta charset='utf-8'><h3>The</h3>`)],
173 name: 'should produce the correct editor state from a pasted HTML h3 element',
177 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><ul class="editor-list-ul"><li value="1" class="editor-listitem"><span data-lexical-text="true">Other side</span></li><li value="2" class="editor-listitem"><span data-lexical-text="true">I must have called</span></li></ul></div>',
180 `<meta charset='utf-8'><ul><li>Other side</li><li>I must have called</li></ul>`,
183 name: 'should produce the correct editor state from a pasted HTML ul element',
187 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><ol class="editor-list-ol"><li value="1" class="editor-listitem"><span data-lexical-text="true">To tell you</span></li><li value="2" class="editor-listitem"><span data-lexical-text="true">I’m sorry</span></li></ol></div>',
190 `<meta charset='utf-8'><ol><li>To tell you</li><li>I’m sorry</li></ol>`,
193 name: 'should produce the correct editor state from pasted HTML ol element',
197 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true">A thousand times</span></p></div>',
198 inputs: [pasteHTML(`<meta charset='utf-8'>A thousand times`)],
199 name: 'should produce the correct editor state from pasted DOM Text Node',
203 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><strong class="editor-text-bold" data-lexical-text="true">Bold</strong></p></div>',
204 inputs: [pasteHTML(`<meta charset='utf-8'><b>Bold</b>`)],
205 name: 'should produce the correct editor state from a pasted HTML b element',
209 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><em class="editor-text-italic" data-lexical-text="true">Italic</em></p></div>',
210 inputs: [pasteHTML(`<meta charset='utf-8'><i>Italic</i>`)],
211 name: 'should produce the correct editor state from a pasted HTML i element',
215 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><em class="editor-text-italic" data-lexical-text="true">Italic</em></p></div>',
216 inputs: [pasteHTML(`<meta charset='utf-8'><em>Italic</em>`)],
217 name: 'should produce the correct editor state from a pasted HTML em element',
221 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span class="editor-text-underline" data-lexical-text="true">Underline</span></p></div>',
222 inputs: [pasteHTML(`<meta charset='utf-8'><u>Underline</u>`)],
223 name: 'should produce the correct editor state from a pasted HTML u element',
227 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><h1 class="editor-heading-h1"><span data-lexical-text="true">Lyrics to Hello by Adele</span></h1><p class="editor-paragraph"><span data-lexical-text="true">A thousand times</span></p></div>',
230 `<meta charset='utf-8'><h1>Lyrics to Hello by Adele</h1>A thousand times`,
233 name: 'should produce the correct editor state from pasted heading node followed by a DOM Text Node',
237 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><a href="https://facebook.com"><span data-lexical-text="true">Facebook</span></a></p></div>',
240 `<meta charset='utf-8'><a href="https://facebook.com">Facebook</a>`,
243 name: 'should produce the correct editor state from a pasted HTML anchor element',
247 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true">Welcome to</span><a href="https://facebook.com"><span data-lexical-text="true">Facebook!</span></a></p></div>',
250 `<meta charset='utf-8'>Welcome to<a href="https://facebook.com">Facebook!</a>`,
253 name: 'should produce the correct editor state from a pasted combination of an HTML text node followed by an anchor node',
257 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true">Welcome to</span><a href="https://facebook.com"><span data-lexical-text="true">Facebook!</span></a><span data-lexical-text="true">We hope you like it here.</span></p></div>',
260 `<meta charset='utf-8'>Welcome to<a href="https://facebook.com">Facebook!</a>We hope you like it here.`,
263 name: 'should produce the correct editor state from a pasted combination of HTML anchor elements and text nodes',
267 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><ul class="editor-list-ul"><li value="1" class="editor-listitem"><span data-lexical-text="true">Hello</span></li><li value="2" class="editor-listitem"><span data-lexical-text="true">from the other</span></li><li value="3" class="editor-listitem"><span data-lexical-text="true">side</span></li></ul></div>',
270 `<meta charset='utf-8'><doesnotexist><ul><li>Hello</li><li>from the other</li><li>side</li></ul></doesnotexist>`,
273 name: 'should ignore DOM node types that do not have transformers, but still process their children.',
277 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><ul class="editor-list-ul"><li value="1" class="editor-listitem"><span data-lexical-text="true">Hello</span></li><li value="2" class="editor-listitem"><span data-lexical-text="true">from the other</span></li><li value="3" class="editor-listitem"><span data-lexical-text="true">side</span></li></ul></div>',
280 `<meta charset='utf-8'><doesnotexist><doesnotexist><ul><li>Hello</li><li>from the other</li><li>side</li></ul></doesnotexist></doesnotexist>`,
283 name: 'should ignore multiple levels of DOM node types that do not have transformers, but still process their children.',
287 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true">Welcome to</span><a href="https://facebook.com"><strong class="editor-text-bold" data-lexical-text="true">Facebook!</strong></a><span data-lexical-text="true">We hope you like it here.</span></p></div>',
290 `<meta charset='utf-8'>Welcome to<b><a href="https://facebook.com">Facebook!</a></b>We hope you like it here.`,
293 name: 'should preserve formatting from HTML tags on deeply nested text nodes.',
297 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true">Welcome to</span><a href="https://facebook.com"><strong class="editor-text-bold" data-lexical-text="true">Facebook!</strong></a><strong class="editor-text-bold" data-lexical-text="true">We hope you like it here.</strong></p></div>',
300 `<meta charset='utf-8'>Welcome to<b><a href="https://facebook.com">Facebook!</a>We hope you like it here.</b>`,
303 name: 'should preserve formatting from HTML tags on deeply nested and top level text nodes.',
307 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span data-lexical-text="true">Welcome to</span><a href="https://facebook.com"><strong class="editor-text-bold editor-text-italic" data-lexical-text="true">Facebook!</strong></a><strong class="editor-text-bold editor-text-italic" data-lexical-text="true">We hope you like it here.</strong></p></div>',
310 `<meta charset='utf-8'>Welcome to<b><i><a href="https://facebook.com">Facebook!</a>We hope you like it here.</i></b>`,
313 name: 'should preserve multiple types of formatting on deeply nested text nodes and top level text nodes',
317 suite.forEach((testUnit, i) => {
318 const name = testUnit.name || 'Test case';
320 test(name + ` (#${i + 1})`, async () => {
321 await applySelectionInputs(testUnit.inputs, update, editor!);
323 // Validate HTML matches
324 expect(container!.innerHTML).toBe(testUnit.expectedHTML);
329 describe('Google Docs', () => {
333 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span style="color: rgb(0, 0, 0);" data-lexical-text="true">Get schwifty!</span></p></div>',
336 `<b style="font-weight:normal;" id="docs-internal-guid-2c706577-7fff-f54a-fe65-12f480020fac"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Get schwifty!</span></b>`,
339 name: 'should produce the correct editor state from Normal text',
343 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><strong class="editor-text-bold" style="color: rgb(0, 0, 0);" data-lexical-text="true">Get schwifty!</strong></p></div>',
346 `<b style="font-weight:normal;" id="docs-internal-guid-9db03964-7fff-c26c-8b1e-9484fb3b54a4"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Get schwifty!</span></b>`,
349 name: 'should produce the correct editor state from bold text',
353 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><em class="editor-text-italic" style="color: rgb(0, 0, 0);" data-lexical-text="true">Get schwifty!</em></p></div>',
356 `<b style="font-weight:normal;" id="docs-internal-guid-9db03964-7fff-c26c-8b1e-9484fb3b54a4"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:italic;font-variant:normal;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Get schwifty!</span></b>`,
359 name: 'should produce the correct editor state from italic text',
363 '<div contenteditable="true" style="user-select: text; white-space: pre-wrap; word-break: break-word;" data-lexical-editor="true"><p class="editor-paragraph"><span class="editor-text-strikethrough" style="color: rgb(0, 0, 0);" data-lexical-text="true">Get schwifty!</span></p></div>',
366 `<b style="font-weight:normal;" id="docs-internal-guid-9db03964-7fff-c26c-8b1e-9484fb3b54a4"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:line-through;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Get schwifty!</span></b>`,
369 name: 'should produce the correct editor state from strikethrough text',
373 suite.forEach((testUnit, i) => {
374 const name = testUnit.name || 'Test case';
376 test(name + ` (#${i + 1})`, async () => {
377 await applySelectionInputs(testUnit.inputs, update, editor!);
379 // Validate HTML matches
380 expect(container!.innerHTML).toBe(testUnit.expectedHTML);
385 describe('W3 spacing', () => {
389 '<p class="editor-paragraph"><span data-lexical-text="true">hello world</span></p>',
390 inputs: [pasteHTML('<span>hello world</span>')],
391 name: 'inline hello world',
395 '<p class="editor-paragraph"><span data-lexical-text="true">hello world</span></p>',
396 inputs: [pasteHTML('<span> hello </span>world ')],
397 name: 'inline hello world (2)',
400 // MS Office got it right
402 '<p class="editor-paragraph"><span data-lexical-text="true"> hello world</span></p>',
404 pasteHTML(' <span style="white-space: pre"> hello </span> world '),
406 name: 'pre + inline (inline collapses with pre)',
410 '<p class="editor-paragraph"><span data-lexical-text="true"> a b</span><span data-lexical-text="true">\t</span><span data-lexical-text="true">c </span></p>',
411 inputs: [pasteHTML('<p style="white-space: pre"> a b\tc </p>')],
412 name: 'white-space: pre (1) (no touchy)',
416 '<p class="editor-paragraph"><span data-lexical-text="true">a b c</span></p>',
417 inputs: [pasteHTML('<p>\ta\tb <span>c\t</span>\t</p>')],
418 name: 'tabs are collapsed',
422 '<p class="editor-paragraph"><span data-lexical-text="true">hello world</span></p>',
431 name: 'remove beginning + end spaces on the block',
435 '<p class="editor-paragraph"><strong class="editor-text-bold" data-lexical-text="true">hello world</strong></p>',
446 name: 'remove beginning + end spaces on the block (2)',
450 '<p class="editor-paragraph"><span data-lexical-text="true">a </span><strong class="editor-text-bold" data-lexical-text="true">b</strong><span data-lexical-text="true"> c</span></p>',
460 name: 'remove beginning + end spaces on the block + anonymous inlines collapsible rules',
464 '<p class="editor-paragraph"><strong class="editor-text-bold" data-lexical-text="true">a </strong><span data-lexical-text="true">b</span></p>',
465 inputs: [pasteHTML('<div><strong>a </strong>b</div>')],
466 name: 'collapsibles and neighbors (1)',
470 '<p class="editor-paragraph"><span data-lexical-text="true">a</span><strong class="editor-text-bold" data-lexical-text="true"> b</strong></p>',
471 inputs: [pasteHTML('<div>a<strong> b</strong></div>')],
472 name: 'collapsibles and neighbors (2)',
476 '<p class="editor-paragraph"><strong class="editor-text-bold" data-lexical-text="true">a </strong><span data-lexical-text="true">b</span></p>',
477 inputs: [pasteHTML('<div><strong>a </strong><span></span>b</div>')],
478 name: 'collapsibles and neighbors (3)',
482 '<p class="editor-paragraph"><span data-lexical-text="true">a</span><strong class="editor-text-bold" data-lexical-text="true"> b</strong></p>',
483 inputs: [pasteHTML('<div>a<span></span><strong> b</strong></div>')],
484 name: 'collapsibles and neighbors (4)',
487 expectedHTML: '<p class="editor-paragraph"><br></p>',
498 '<p class="editor-paragraph"><span data-lexical-text="true">a</span></p>',
499 inputs: [pasteHTML('<span> </span><span>a</span>')],
500 name: 'redundant inline at start',
504 '<p class="editor-paragraph"><span data-lexical-text="true">a</span></p>',
505 inputs: [pasteHTML('<span>a</span><span> </span>')],
506 name: 'redundant inline at end',
510 '<p class="editor-paragraph"><span data-lexical-text="true">a</span></p><p class="editor-paragraph"><span data-lexical-text="true">b</span></p>',
523 name: 'collapsible spaces with nested structures',
527 '<p class="editor-paragraph"><strong class="editor-text-bold" data-lexical-text="true">a b</strong></p>',
540 name: 'collapsible spaces with nested structures (3)',
544 '<p class="editor-paragraph"><span data-lexical-text="true">a</span><br><span data-lexical-text="true">b</span></p>',
554 name: 'forced line break should remain',
558 '<p class="editor-paragraph"><span data-lexical-text="true">a</span><br><span data-lexical-text="true">b</span></p>',
568 name: 'forced line break with tabs',
572 '<p class="editor-paragraph"><span data-lexical-text="true">paragraph1</span></p><p class="editor-paragraph"><span data-lexical-text="true">paragraph2</span></p>',
575 '\n<p class="p1">paragraph1</p>\n<p class="p1">paragraph2</p>\n',
578 name: 'two Apple Notes paragraphs',
582 '<p class="editor-paragraph"><span data-lexical-text="true">line 1</span><br><span data-lexical-text="true">line 2</span></p><p class="editor-paragraph"><br></p><p class="editor-paragraph"><span data-lexical-text="true">paragraph 1</span></p><p class="editor-paragraph"><span data-lexical-text="true">paragraph 2</span></p>',
585 '\n<p class="p1">line 1<br>\nline 2</p>\n<p class="p2"><br></p>\n<p class="p1">paragraph 1</p>\n<p class="p1">paragraph 2</p>\n',
588 name: 'two Apple Notes lines + two paragraphs separated by an empty paragraph',
592 '<p class="editor-paragraph"><span data-lexical-text="true">line 1</span><br><span data-lexical-text="true">line 2</span></p><p class="editor-paragraph"><br></p><p class="editor-paragraph"><span data-lexical-text="true">paragraph 1</span></p><p class="editor-paragraph"><span data-lexical-text="true">paragraph 2</span></p>',
595 '\n<p class="p1">line 1<br>\nline 2</p>\n<p class="p2">\n<br>\n</p>\n<p class="p1">paragraph 1</p>\n<p class="p1">paragraph 2</p>\n',
598 name: 'two lines + two paragraphs separated by an empty paragraph (2)',
602 '<p class="editor-paragraph"><span data-lexical-text="true">line 1</span><br><span data-lexical-text="true">line 2</span></p>',
605 '<p class="p1"><span>line 1</span><span><br></span><span>line 2</span></p>',
608 name: 'two lines and br in spans',
612 '<ol class="editor-list-ol"><li value="1" class="editor-listitem"><span data-lexical-text="true">1</span><br><span data-lexical-text="true">2</span></li><li value="2" class="editor-listitem"><br></li><li value="3" class="editor-listitem"><span data-lexical-text="true">3</span></li></ol>',
614 pasteHTML('<ol><li>1<div></div>2</li><li></li><li>3</li></ol>'),
616 name: 'empty block node in li behaves like a line break',
620 '<p class="editor-paragraph"><span data-lexical-text="true">1</span><br><span data-lexical-text="true">2</span></p>',
621 inputs: [pasteHTML('<div>1<div></div>2</div>')],
622 name: 'empty block node in div behaves like a line break',
626 '<p class="editor-paragraph"><span data-lexical-text="true">12</span></p>',
627 inputs: [pasteHTML('<div>1<text></text>2</div>')],
628 name: 'empty inline node does not behave like a line break',
632 '<p class="editor-paragraph"><span data-lexical-text="true">1</span></p><p class="editor-paragraph"><span data-lexical-text="true">2</span></p>',
633 inputs: [pasteHTML('<div><div>1</div><div></div><div>2</div></div>')],
634 name: 'empty block node between non inline siblings does not behave like a line break',
638 '<p class="editor-paragraph"><span data-lexical-text="true">a</span></p><p class="editor-paragraph"><span data-lexical-text="true">b b</span></p><p class="editor-paragraph"><span data-lexical-text="true">c</span></p><p class="editor-paragraph"><span data-lexical-text="true">z</span></p><p class="editor-paragraph"><span data-lexical-text="true">d e</span></p><p class="editor-paragraph"><span data-lexical-text="true">fg</span></p>',
641 `<div>a<div>b b<div>c<div><div></div>z</div></div>d e</div>fg</div>`,
648 '<ol class="editor-list-ol"><li value="1" class="editor-listitem"><span data-lexical-text="true">1</span></li><li value="2" class="editor-listitem"><br></li><li value="3" class="editor-listitem"><span data-lexical-text="true">3</span></li></ol>',
649 inputs: [pasteHTML('<ol><li>1</li><li><br /></li><li>3</li></ol>')],
650 name: 'only br in a li',
654 '<p class="editor-paragraph"><span data-lexical-text="true">1</span></p><p class="editor-paragraph"><span data-lexical-text="true">2</span></p><p class="editor-paragraph"><span data-lexical-text="true">3</span></p>',
655 inputs: [pasteHTML('1<p>2<br /></p>3')],
656 name: 'last br in a block node is ignored',
660 suite.forEach((testUnit, i) => {
661 const name = testUnit.name || 'Test case';
663 // eslint-disable-next-line no-only-tests/no-only-tests, dot-notation
664 const test_ = 'only' in testUnit && testUnit['only'] ? test.only : test;
665 test_(name + ` (#${i + 1})`, async () => {
666 await applySelectionInputs(testUnit.inputs, update, editor!);
668 // Validate HTML matches
669 expect((container!.firstChild as HTMLElement).innerHTML).toBe(
670 testUnit.expectedHTML,