]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/lexical/table/__tests__/unit/LexicalTableRowNode.test.ts
cf110634b5b0b44d8aab33481517ef4d34c3295d
[bookstack] / resources / js / wysiwyg / lexical / table / __tests__ / unit / LexicalTableRowNode.test.ts
1 /**
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  *
7  */
8
9 import {$createTableRowNode} from '@lexical/table';
10 import {initializeUnitTest} from 'lexical/src/__tests__/utils';
11
12 const editorConfig = Object.freeze({
13   namespace: '',
14   theme: {
15     tableRow: 'test-table-row-class',
16   },
17 });
18
19 describe('LexicalTableRowNode tests', () => {
20   initializeUnitTest((testEnv) => {
21     test('TableRowNode.constructor', async () => {
22       const {editor} = testEnv;
23
24       await editor.update(() => {
25         const rowNode = $createTableRowNode();
26
27         expect(rowNode).not.toBe(null);
28       });
29
30       expect(() => $createTableRowNode()).toThrow();
31     });
32
33     test('TableRowNode.createDOM()', async () => {
34       const {editor} = testEnv;
35
36       await editor.update(() => {
37         const rowNode = $createTableRowNode();
38         expect(rowNode.createDOM(editorConfig).outerHTML).toBe(
39           `<tr class="${editorConfig.theme.tableRow}"></tr>`,
40         );
41
42         const rowHeight = 36;
43         const rowWithCustomHeightNode = $createTableRowNode(36);
44         expect(rowWithCustomHeightNode.createDOM(editorConfig).outerHTML).toBe(
45           `<tr style="height: ${rowHeight}px;" class="${editorConfig.theme.tableRow}"></tr>`,
46         );
47       });
48     });
49   });
50 });