Skip to content

Commit d777ddb

Browse files
committed
test: fill missing dates with custom string
1 parent 1970753 commit d777ddb

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

packages/cubejs-client-core/src/tests/ResultSet.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,66 @@ describe('ResultSet', () => {
14781478
]);
14791479
});
14801480

1481+
test('fill missing dates with custom string', () => {
1482+
const resultSet = new ResultSet({
1483+
query: {
1484+
measures: ['Orders.total'],
1485+
timeDimensions: [
1486+
{
1487+
dimension: 'Orders.createdAt',
1488+
granularity: 'day',
1489+
dateRange: ['2020-01-08T00:00:00.000', '2020-01-11T23:59:59.999']
1490+
}
1491+
],
1492+
filters: [],
1493+
timezone: 'UTC'
1494+
},
1495+
data: [
1496+
{
1497+
'Orders.createdAt': '2020-01-08T00:00:00.000',
1498+
'Orders.total': 1
1499+
},
1500+
{
1501+
'Orders.createdAt': '2020-01-10T00:00:00.000',
1502+
'Orders.total': 10
1503+
}
1504+
],
1505+
annotation: {
1506+
measures: {},
1507+
dimensions: {},
1508+
segments: {},
1509+
timeDimensions: {
1510+
'Orders.createdAt': {
1511+
title: 'Orders Created at',
1512+
shortTitle: 'Created at',
1513+
type: 'time'
1514+
}
1515+
}
1516+
}
1517+
});
1518+
1519+
expect(resultSet.tablePivot({
1520+
'fillWithValue': 'N/A'
1521+
})).toEqual([
1522+
{
1523+
'Orders.createdAt.day': '2020-01-08T00:00:00.000',
1524+
'Orders.total': 1
1525+
},
1526+
{
1527+
'Orders.createdAt.day': '2020-01-09T00:00:00.000',
1528+
'Orders.total': "N/A"
1529+
},
1530+
{
1531+
'Orders.createdAt.day': '2020-01-10T00:00:00.000',
1532+
'Orders.total': 10
1533+
},
1534+
{
1535+
'Orders.createdAt.day': '2020-01-11T00:00:00.000',
1536+
'Orders.total': "N/A"
1537+
}
1538+
]);
1539+
});
1540+
14811541
test('same dimension and time dimension without granularity', () => {
14821542
const resultSet = new ResultSet({
14831543
query: {

0 commit comments

Comments
 (0)