@@ -572,6 +572,66 @@ test("unit tests", function(t) {
572
572
t . finish ( ) ;
573
573
} )
574
574
575
+ t . test ( "table (rowspan/colspan) with thead and tbody" , function ( t ) {
576
+ var html = `<table>
577
+ <thead>
578
+ <tr>
579
+ <th rowspan="2">Col A</th>
580
+ <th colspan="2">Col B & C</th>
581
+ <th rowspan="2">Col D</th>
582
+ </tr>
583
+ <tr>
584
+ <th>Col B</th>
585
+ <th>Col C</th>
586
+ </tr>
587
+ </thead>
588
+ <tbody>
589
+ <tr>
590
+ <td rowspan="2">Cell A1 & A2</td>
591
+ <td>Cell B1</td>
592
+ <td rowspan="2">Cell C1 & C2</td>
593
+ <td>Cell D1</td>
594
+ </tr>
595
+ <tr>
596
+ <td>Cell B2</td>
597
+ <td>Cell D2</td>
598
+ </tr>
599
+ </tbody>
600
+ </table>` ;
601
+ var ret = htmlToPdfMake ( html , { window :window } ) ;
602
+ if ( debug ) console . log ( JSON . stringify ( ret ) ) ;
603
+ t . check ( Array . isArray ( ret ) && ret . length === 1 , "return is OK" ) ;
604
+ ret = ret [ 0 ] ;
605
+
606
+ t . check (
607
+ ret . table &&
608
+ Array . isArray ( ret . table . body ) &&
609
+ ret . table . body . length === 4 , "base" ) ;
610
+ t . check (
611
+ ret . table . body [ 0 ] . length === 4 &&
612
+ ret . table . body [ 0 ] [ 0 ] . text === "Col A" &&
613
+ ret . table . body [ 0 ] [ 1 ] . text === "Col B & C" &&
614
+ ret . table . body [ 0 ] [ 3 ] . text === "Col D" &&
615
+ ret . table . body [ 1 ] . length === 4 &&
616
+ ret . table . body [ 1 ] [ 1 ] . text === "Col B" &&
617
+ ret . table . body [ 1 ] [ 2 ] . text === "Col C" , "header" ) ;
618
+ t . check (
619
+ ret . table . body [ 2 ] . length === 4 &&
620
+ ret . table . body [ 2 ] [ 0 ] . text === "Cell A1 & A2" &&
621
+ ret . table . body [ 2 ] [ 1 ] . text === "Cell B1" &&
622
+ ret . table . body [ 2 ] [ 2 ] . text === "Cell C1 & C2" &&
623
+ ret . table . body [ 2 ] [ 3 ] . text === "Cell D1" , "row 1" ) ;
624
+ t . check (
625
+ ret . table . body [ 3 ] . length === 4 &&
626
+ ret . table . body [ 3 ] [ 1 ] . text === "Cell B2" &&
627
+ ret . table . body [ 3 ] [ 3 ] . text === "Cell D2" , "row 2" ) ;
628
+ t . check (
629
+ Array . isArray ( ret . style ) &&
630
+ ret . style [ 0 ] === 'html-table' , "table style" ) ;
631
+
632
+ t . finish ( ) ;
633
+ } )
634
+
575
635
t . test ( "img" , function ( t ) {
576
636
var ret = htmlToPdfMake ( '<img width="10" style="height:10px" src="data:image/jpeg;base64,...encodedContent...">' , { window :window } ) ;
577
637
if ( debug ) console . log ( JSON . stringify ( ret ) ) ;
0 commit comments