Skip to content

Commit 0c01ed5

Browse files
committed
Fixed tables in partialBlockToBlockForTesting
1 parent 6b0de88 commit 0c01ed5

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

tests/src/unit/core/formatConversion/formatConversionTestUtil.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
PartialBlock,
1010
PartialInlineContent,
1111
PartialTableCell,
12+
PartialTableContent,
1213
StyledText,
1314
StyleSchema,
1415
TableCell,
@@ -153,10 +154,10 @@ export function partialBlockToBlockForTesting<
153154
);
154155

155156
if (contentType === "inline") {
156-
const content = withDefaults.content as InlineContent<I, S>[] | undefined;
157+
const content = withDefaults.content as PartialInlineContent<I, S>;
157158
withDefaults.content = partialContentToInlineContent(content) as any;
158159
} else if (contentType === "table") {
159-
const content = withDefaults.content as TableContent<I, S> | undefined;
160+
const content = withDefaults.content as PartialTableContent<I, S>;
160161
withDefaults.content = {
161162
type: "tableContent",
162163
columnWidths:
@@ -167,7 +168,34 @@ export function partialBlockToBlockForTesting<
167168
headerCols: content?.headerCols || undefined,
168169
rows:
169170
content?.rows.map((row) => ({
170-
cells: row.cells.map((cell) => partialContentToInlineContent(cell)),
171+
cells: row.cells.map((cell) =>
172+
typeof cell === "object" &&
173+
"type" in cell &&
174+
cell.type === "tableCell"
175+
? {
176+
type: "tableCell",
177+
props: {
178+
backgroundColor: "default",
179+
colspan: 1,
180+
rowspan: 1,
181+
textAlignment: "left",
182+
textColor: "default",
183+
...cell.props,
184+
},
185+
content: partialContentToInlineContent(cell.content),
186+
}
187+
: {
188+
type: "tableCell",
189+
props: {
190+
backgroundColor: "default",
191+
colspan: 1,
192+
rowspan: 1,
193+
textAlignment: "left",
194+
textColor: "default",
195+
},
196+
content: partialContentToInlineContent(cell),
197+
}
198+
),
171199
})) || [],
172200
} as any;
173201
}

0 commit comments

Comments
 (0)