@@ -1112,23 +1112,6 @@ describe('renderTableCell', () => {
11121112 } ) ;
11131113
11141114 describe ( 'spacing.before margin-top rendering' , ( ) => {
1115- const baseMeasure : ParagraphMeasure = {
1116- kind : 'paragraph' ,
1117- lines : [
1118- {
1119- fromRun : 0 ,
1120- fromChar : 0 ,
1121- toRun : 0 ,
1122- toChar : 10 ,
1123- width : 100 ,
1124- ascent : 12 ,
1125- descent : 4 ,
1126- lineHeight : 20 ,
1127- } ,
1128- ] ,
1129- totalHeight : 20 ,
1130- } ;
1131-
11321115 it ( 'applies margin-top only for positive spacing.before' , ( ) => {
11331116 const para1 : ParagraphBlock = {
11341117 kind : 'paragraph' ,
@@ -1152,7 +1135,7 @@ describe('renderTableCell', () => {
11521135 } ;
11531136
11541137 const cellMeasure : TableCellMeasure = {
1155- blocks : [ baseMeasure , baseMeasure , baseMeasure ] ,
1138+ blocks : [ paragraphMeasure , paragraphMeasure , paragraphMeasure ] ,
11561139 width : 120 ,
11571140 height : 80 ,
11581141 gridColumnStart : 0 ,
@@ -1250,6 +1233,40 @@ describe('renderTableCell', () => {
12501233 const fullWrapper = ( fullCell . firstElementChild as HTMLElement ) . firstElementChild as HTMLElement ;
12511234 expect ( fullWrapper . style . marginTop ) . toBe ( '11px' ) ;
12521235 } ) ;
1236+
1237+ it ( 'applies both margin-top and margin-bottom when paragraph has spacing.before and spacing.after' , ( ) => {
1238+ const para : ParagraphBlock = {
1239+ kind : 'paragraph' ,
1240+ id : 'para-before-and-after' ,
1241+ runs : [ { text : 'Both spacing' , fontFamily : 'Arial' , fontSize : 16 } ] ,
1242+ attrs : { spacing : { before : 12 , after : 18 } } ,
1243+ } ;
1244+
1245+ const cellMeasure : TableCellMeasure = {
1246+ blocks : [ paragraphMeasure ] ,
1247+ width : 120 ,
1248+ height : 60 ,
1249+ gridColumnStart : 0 ,
1250+ colSpan : 1 ,
1251+ rowSpan : 1 ,
1252+ } ;
1253+
1254+ const cell : TableCell = {
1255+ id : 'cell-before-and-after' ,
1256+ blocks : [ para ] ,
1257+ attrs : { } ,
1258+ } ;
1259+
1260+ const { cellElement } = renderTableCell ( {
1261+ ...createBaseDeps ( ) ,
1262+ cellMeasure,
1263+ cell,
1264+ } ) ;
1265+
1266+ const paraWrapper = ( cellElement . firstElementChild as HTMLElement ) . firstElementChild as HTMLElement ;
1267+ expect ( paraWrapper . style . marginTop ) . toBe ( '12px' ) ;
1268+ expect ( paraWrapper . style . marginBottom ) . toBe ( '18px' ) ;
1269+ } ) ;
12531270 } ) ;
12541271
12551272 describe ( 'list marker rendering' , ( ) => {
0 commit comments