File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
packages/cubejs-client-core/src/tests Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -1418,6 +1418,66 @@ describe('ResultSet', () => {
14181418 ] ) ;
14191419 } ) ;
14201420
1421+ test ( 'fill missing dates with custom value' , ( ) => {
1422+ const resultSet = new ResultSet ( {
1423+ query : {
1424+ measures : [ 'Orders.total' ] ,
1425+ timeDimensions : [
1426+ {
1427+ dimension : 'Orders.createdAt' ,
1428+ granularity : 'day' ,
1429+ dateRange : [ '2020-01-08T00:00:00.000' , '2020-01-11T23:59:59.999' ]
1430+ }
1431+ ] ,
1432+ filters : [ ] ,
1433+ timezone : 'UTC'
1434+ } ,
1435+ data : [
1436+ {
1437+ 'Orders.createdAt' : '2020-01-08T00:00:00.000' ,
1438+ 'Orders.total' : 1
1439+ } ,
1440+ {
1441+ 'Orders.createdAt' : '2020-01-10T00:00:00.000' ,
1442+ 'Orders.total' : 10
1443+ }
1444+ ] ,
1445+ annotation : {
1446+ measures : { } ,
1447+ dimensions : { } ,
1448+ segments : { } ,
1449+ timeDimensions : {
1450+ 'Orders.createdAt' : {
1451+ title : 'Orders Created at' ,
1452+ shortTitle : 'Created at' ,
1453+ type : 'time'
1454+ }
1455+ }
1456+ }
1457+ } ) ;
1458+
1459+ expect ( resultSet . tablePivot ( {
1460+ 'fillWithValue' : 5
1461+ } ) ) . toEqual ( [
1462+ {
1463+ 'Orders.createdAt.day' : '2020-01-08T00:00:00.000' ,
1464+ 'Orders.total' : 1
1465+ } ,
1466+ {
1467+ 'Orders.createdAt.day' : '2020-01-09T00:00:00.000' ,
1468+ 'Orders.total' : 5
1469+ } ,
1470+ {
1471+ 'Orders.createdAt.day' : '2020-01-10T00:00:00.000' ,
1472+ 'Orders.total' : 10
1473+ } ,
1474+ {
1475+ 'Orders.createdAt.day' : '2020-01-11T00:00:00.000' ,
1476+ 'Orders.total' : 5
1477+ }
1478+ ] ) ;
1479+ } ) ;
1480+
14211481 test ( 'same dimension and time dimension without granularity' , ( ) => {
14221482 const resultSet = new ResultSet ( {
14231483 query : {
You can’t perform that action at this time.
0 commit comments