@@ -231,34 +231,36 @@ suite('<google-chart>', function() {
231231 } ) ;
232232
233233 suite ( 'Data Source Types' , function ( ) {
234- test ( '[rows] and [cols]' , function ( done ) {
235- chart . cols = [
236- { 'label' : 'Data' , 'type' : 'string' } ,
237- { 'label' : 'Value' , 'type' : 'number' }
238- ] ;
234+ // Waits for the event reporting a successful render. Invalid or missing data sources do not
235+ // trigger the event and will timeout the tests.
236+ function waitForRender ( done : ( ) => void ) {
237+ chart . addEventListener ( 'google-chart-ready' , ( ) => void done ( ) ) ;
238+ }
239+ test ( '[rows] and [cols] without type' , function ( done ) {
240+ chart . cols = [ 'Data' , 'Value' ] ;
239241 chart . rows = [
240242 [ 'Something' , 1 ]
241243 ] ;
242- chart . addEventListener ( 'google-chart-ready' , function ( ) {
243- done ( ) ;
244- } ) ;
244+ waitForRender ( done ) ;
245245 } ) ;
246246
247- test ( '[rows] and [cols] with date string repr is broken' , function ( done ) {
248- chart . cols = [ { 'type' : 'date' } ] ;
249- chart . rows = [ [ 'Date(1789, 3, 30)' ] ] ;
250- waitCheckAndDone ( function ( ) {
251- const chartDiv = chart . shadowRoot ! . getElementById ( 'chartdiv' ) ! ;
252- return chartDiv . innerHTML ==
253- 'Error: Type mismatch. Value Date(1789, 3, 30) ' +
254- 'does not match type date in column index 0' ;
255- } , done ) ;
247+ test ( '[rows] and [cols] with type' , function ( done ) {
248+ chart . type = 'timeline' ;
249+ chart . cols = [
250+ 'Data' ,
251+ { type : 'date' , label : 'Start' } ,
252+ { type : 'date' , label : 'End' }
253+ ] ;
254+ chart . rows = [ [
255+ 'Something' ,
256+ 'Date(2024, 6, 1)' ,
257+ 'Date(2024, 7, 1)'
258+ ] ] ;
259+ waitForRender ( done ) ;
256260 } ) ;
257261 var setDataAndWaitForRender = function ( data : DataTableLike | string , done : ( ) => void ) {
258262 chart . data = data ;
259- chart . addEventListener ( 'google-chart-ready' , function ( ) {
260- done ( ) ;
261- } ) ;
263+ waitForRender ( done ) ;
262264 } ;
263265 test ( '[data] is 2D Array' , function ( done ) {
264266 setDataAndWaitForRender ( [ [ 'Data' , 'Value' ] , [ 'Something' , 1 ] ] , done ) ;
0 commit comments