@@ -129,6 +129,41 @@ describe('@api Table ', function () {
129129 ] ;
130130 expect ( table . toString ( ) ) . toEqual ( expected . join ( '\n' ) ) ;
131131 } ) ;
132+ describe ( 'debugging' , ( ) => {
133+ afterEach ( ( ) => Table . reset ( ) ) ;
134+ it ( 'is not accessible when disabled' , ( ) => {
135+ let table = new Table ( ) ;
136+ expect ( table . messages ) . toBeUndefined ( ) ;
137+ } ) ;
138+ it ( 'warns of missing cells' , ( ) => {
139+ let table = new Table ( { debug : true } ) ;
140+ table . push ( [ { rowSpan : 2 } ] , [ { } ] ) ;
141+ table . toString ( ) ;
142+ expect ( table . messages ) . toEqual ( [ 'Missing cell at 0-1.' ] ) ;
143+ } ) ;
144+ it ( 'provides cell info' , ( ) => {
145+ let table = new Table ( { debug : 2 } ) ;
146+ table . push ( [ 'a' , 'b' , { content : 'c' , rowSpan : 2 } ] , [ { content : 'd' , colSpan : 2 } ] ) ;
147+ table . toString ( ) ;
148+ expect ( table . messages ) . toContain ( '0-0: 1x1 Cell a' ) ;
149+ expect ( table . messages ) . toContain ( '0-1: 1x1 Cell b' ) ;
150+ expect ( table . messages ) . toContain ( '0-2: 2x1 Cell c' ) ;
151+ expect ( table . messages ) . toContain ( '1-0: 1x2 Cell d' ) ;
152+ } ) ;
153+ it ( 'provides rowSpan and colSpan cell debug info' , ( ) => {
154+ let table = new Table ( { debug : 3 } ) ;
155+ table . push ( [ 'a' , 'b' , { content : 'c' , rowSpan : 2 } ] , [ { content : 'd' , colSpan : 2 } ] ) ;
156+ table . toString ( ) ;
157+ expect ( table . messages ) . toContain ( '1-1: 1x1 ColSpanCell' ) ;
158+ expect ( table . messages ) . toContain ( '1-2: 1x1 RowSpanCell for c' ) ;
159+ } ) ;
160+ it ( 'provides debug info' , ( ) => {
161+ let table = new Table ( { debug : 3 } ) ;
162+ table . push ( [ { } , { } ] , [ { } , { } ] ) ;
163+ table . toString ( ) ;
164+ expect ( table . messages ) . toContain ( 'Max rows: 2; Max cols: 2' ) ;
165+ } ) ;
166+ } ) ;
132167} ) ;
133168
134169/*
0 commit comments