Skip to content

Commit

Permalink
fix: Tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL committed Jan 22, 2025
1 parent 3cd5f9a commit a1ee990
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ describe('LexicalSelection tests', () => {
return $createHeadingNode('h1');
});
expect(JSON.stringify(testEditor._pendingEditorState?.toJSON())).toBe(
'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"children":[{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":3,"rowSpan":1},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":1,"rowSpan":1}],"direction":null,"format":"","indent":0,"type":"tablerow","version":1}],"direction":null,"format":"","indent":0,"type":"table","version":1},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"root","version":1}}',
'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[{"children":[{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":3,"rowSpan":1,"verticalAlign":null},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"","type":"text","version":1}],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"tablecell","version":1,"backgroundColor":null,"colSpan":1,"headerState":1,"rowSpan":1,"verticalAlign":null}],"direction":null,"format":"","indent":0,"type":"tablerow","version":1}],"direction":null,"format":"","indent":0,"type":"table","version":1},{"children":[],"direction":null,"format":"","indent":0,"type":"heading","version":1,"tag":"h1"}],"direction":null,"format":"","indent":0,"type":"root","version":1}}',
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ describe('LexicalTableCellNode tests', () => {
expect(cellWithCustomWidthNode.createDOM(editorConfig).outerHTML).toBe(
`<td style="width: ${cellWidth}px;" class="${editorConfig.theme.tableCell}"></td>`,
);
const verticalAlign = 'top';
const cellWithVerticalAlignNode = $createTableCellNode(
TableCellHeaderStates.NO_STATUS,
);
cellWithVerticalAlignNode.setVerticalAlign(verticalAlign);
expect(
cellWithVerticalAlignNode.createDOM(editorConfig).outerHTML,
).toBe(
`<td style="vertical-align: ${verticalAlign};" class="${editorConfig.theme.tableCell}"></td>`,
);
});
});
});
Expand Down
21 changes: 11 additions & 10 deletions packages/lexical-table/src/__tests__/unit/LexicalTableNode.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ describe('LexicalTableNode tests', () => {
$insertDataTransferForRichText(dataTransfer, selection, editor);
});
// Make sure paragraph is inserted inside empty cells
const emptyCell = '<td><p><br></p></td>';
const emptyCell =
'<td style="vertical-align: top"><p><br></p></td>';
expectTableHtmlToBeEqual(
testEnv.innerHTML,
html`
Expand All @@ -297,19 +298,19 @@ describe('LexicalTableNode tests', () => {
<col style="width: 200px;" />
</colgroup>
<tr>
<td>
<td style="vertical-align: top">
<p dir="ltr">
<span data-lexical-text="true">Hello there</span>
</p>
</td>
<td>
<td style="vertical-align: top">
<p dir="ltr">
<span data-lexical-text="true">General Kenobi!</span>
</p>
</td>
</tr>
<tr>
<td>
<td style="vertical-align: top">
<p dir="ltr">
<span data-lexical-text="true">Lexical is nice</span>
</p>
Expand Down Expand Up @@ -659,34 +660,34 @@ describe('LexicalTableNode tests', () => {
<col style="width: 171px" />
</colgroup>
<tr style="height: 21px;">
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<strong data-lexical-text="true">Surface</strong>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<em data-lexical-text="true">MWP_WORK_LS_COMPOSER</em>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p style="text-align: right;">
<span data-lexical-text="true">77349</span>
</p>
</td>
</tr>
<tr style="height: 21px;">
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<span data-lexical-text="true">Lexical</span>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<span data-lexical-text="true">XDS_RICH_TEXT_AREA</span>
</p>
</td>
<td>
<td style="vertical-align: bottom">
<p dir="ltr">
<span data-lexical-text="true">sdvd</span>
<strong data-lexical-text="true">sdfvsfs</strong>
Expand Down
Loading

0 comments on commit a1ee990

Please sign in to comment.