@@ -301,7 +301,7 @@ describe('sql-series. toTimeSeries unit tests', () => {
301
301
} ;
302
302
303
303
it ( 'should return an empty array when there are no series' , ( ) => {
304
- const result = toTimeSeries ( true , selfMock ) ;
304
+ const result = toTimeSeries ( true , true , selfMock ) ;
305
305
expect ( result ) . toEqual ( [ ] ) ;
306
306
} ) ;
307
307
@@ -313,7 +313,7 @@ describe('sql-series. toTimeSeries unit tests', () => {
313
313
] ;
314
314
selfMock . keys = [ ] ;
315
315
316
- const result = toTimeSeries ( true , selfMock ) ;
316
+ const result = toTimeSeries ( true , true , selfMock ) ;
317
317
expect ( result ) . toEqual ( [ { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1000 ] } , { "config" : { "links" : [ ] } , "name" : "value" , "values" : [ 10 ] } ] , "length" : 1 , "refId" : undefined } ] ) ;
318
318
} ) ;
319
319
@@ -328,22 +328,21 @@ describe('sql-series. toTimeSeries unit tests', () => {
328
328
] ;
329
329
selfMock . keys = [ ] ;
330
330
331
- const result = toTimeSeries ( true , selfMock ) ;
331
+ const result = toTimeSeries ( true , true , selfMock ) ;
332
332
expect ( result ) . toEqual ( [ { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1000 , 2000 ] } , { "config" : { "links" : [ ] } , "name" : "value" , "values" : [ 10 , 20 ] } ] , "length" : 2 , "refId" : undefined } ] ) ;
333
333
} ) ;
334
334
335
335
it ( 'should extrapolate data points when required' , ( ) => {
336
336
let selfMock = { "from" : 0 , "keys" : [ ] , "meta" : [ { "name" : "time" , "type" : "UInt32" } , { "name" : "value" , "type" : "UInt64" } ] , "series" : [ { "time" : 1736332351828 , "value" : 32 } , { "time" : 1736332336828 , "value" : 34 } , { "time" : 1736332321828 , "value" : 36 } , { "time" : 1736332306828 , "value" : 38 } , { "time" : 1736332291828 , "value" : 40 } , { "time" : 1736332276828 , "value" : 42 } , { "time" : 1736332261828 , "value" : 44 } , { "time" : 1736332246828 , "value" : 46 } , { "time" : 1736332231828 , "value" : 48 } , { "time" : 1736332216828 , "value" : 50 } ] , "tillNow" : true , "to" : 1000 }
337
- const result = toTimeSeries ( true , selfMock ) ;
337
+ const result = toTimeSeries ( true , true , selfMock ) ;
338
338
expect ( result ) . toEqual ( [ { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1736332351828 , 1736332336828 , 1736332321828 , 1736332306828 , 1736332291828 , 1736332276828 , 1736332261828 , 1736332246828 , 1736332231828 , 1736332216828 ] } , { "config" : { "links" : [ ] } , "name" : "value" , "values" : [ 32 , 34 , 36 , 38 , 40 , 42 , 44 , 46 , 48 , 48.2 ] } ] , "length" : 10 , "refId" : undefined } ] ) ;
339
339
340
340
selfMock = { "from" : 0 , "keys" : [ ] , "meta" : [ { "name" : "time" , "type" : "UInt32" } , { "name" : "value" , "type" : "UInt64" } ] , "series" : [ { "time" : 1736332580592 , "value" : 52 } , { "time" : 1736332550592 , "value" : 54 } , { "time" : 1736332520592 , "value" : 56 } ] , "tillNow" : true , "to" : 1000 }
341
- const resultNonExtrapolated = toTimeSeries ( true , selfMock ) ;
341
+ const resultNonExtrapolated = toTimeSeries ( true , true , selfMock ) ;
342
342
expect ( resultNonExtrapolated ) . toEqual ( [ { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1736332580592 , 1736332550592 , 1736332520592 ] } , { "config" : { "links" : [ ] } , "name" : "value" , "values" : [ 52 , 54 , 56 ] } ] , "length" : 3 , "refId" : undefined } ] ) ;
343
-
344
343
} ) ;
345
344
346
- it ( 'should handle composite keys correctly' , ( ) => {
345
+ it ( 'should handle composite keys correctly with nullifySparse=true ' , ( ) => {
347
346
selfMock . series = [
348
347
{ time : 1000 , category : 'A' , value : 10 } ,
349
348
{ time : 2000 , category : 'B' , value : 20 } ,
@@ -356,10 +355,11 @@ describe('sql-series. toTimeSeries unit tests', () => {
356
355
selfMock . keys = [ 'category' ] ;
357
356
selfMock . tillNow = false ;
358
357
359
- const result = toTimeSeries ( true , selfMock ) ;
358
+ const result = toTimeSeries ( true , true , selfMock ) ;
360
359
expect ( result ) . toEqual ( [ { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1000 , 1000 ] } , { "config" : { "links" : [ ] } , "name" : "A" , "values" : [ 1000 , 10 ] } ] , "length" : 2 , "refId" : undefined } , { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1000 , 1000 , 2000 , 2000 ] } , { "config" : { "links" : [ ] } , "name" : "B" , "values" : [ null , null , 2000 , 20 ] } ] , "length" : 4 , "refId" : undefined } ] )
361
360
} ) ;
362
361
362
+
363
363
it ( 'should handle null values correctly' , ( ) => {
364
364
selfMock . series = [
365
365
{ time : 1000 , value : null } ,
@@ -371,7 +371,7 @@ describe('sql-series. toTimeSeries unit tests', () => {
371
371
] ;
372
372
selfMock . keys = [ ] ;
373
373
374
- const result = toTimeSeries ( false , selfMock ) ;
374
+ const result = toTimeSeries ( false , true , selfMock ) ;
375
375
expect ( result ) . toEqual ( [ { "fields" : [ { "config" : { "links" : [ ] } , "name" : "time" , "type" : "time" , "values" : [ 1000 , 2000 ] } , { "config" : { "links" : [ ] } , "name" : "value" , "values" : [ null , 20 ] } ] , "length" : 2 , "refId" : undefined } ] ) ;
376
376
} ) ;
377
377
} ) ;
0 commit comments