From 2f59919f84d15aa0f61065a6160c389c48b9fa75 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Sun, 7 Oct 2018 00:29:12 +0200 Subject: [PATCH] Dimension metadata test --- test/acceptance/aggregation.js | 50 ++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 427983e4..d3ccb34a 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -878,8 +878,7 @@ describe('aggregation', function () { }); }); - it('time dimensions', - function (done) { + it('time dimensions', function (done) { this.mapConfig = createVectorMapConfig([ { type: 'cartodb', @@ -891,7 +890,9 @@ describe('aggregation', function () { dimensions: { dow: { column: 'date', - group_by: 'dayOfWeek' + group: { + units: 'dayOfWeek' + } } } } @@ -916,7 +917,50 @@ describe('aggregation', function () { }); }); + // TODO: cyclic with timezone, serial, serial with count/starting/timezone, serial iso / with timezone + it('time dimensions stats', function (done) { + this.mapConfig = createVectorMapConfig([ + { + type: 'cartodb', + options: { + sql: POINTS_SQL_TIMESTAMP_1, + dates_as_numbers: true, + aggregation: { + threshold: 1, + dimensions: { + dow: { + column: 'date', + group: { + units: 'dayOfWeek' + } + } + } + }, + metadata: { + dimensions: true + } + } + } + ]); + + this.testClient = new TestClient(this.mapConfig); + this.testClient.getLayergroup(function(err, layergroup) { + assert.ifError(err); + const expectedDimensions = { + dow: + { params: + { time: 'to_timestamp("date")', + timezone: 'utc', + units: 'dayOfWeek', + count: 1 }, + min: 4, + max: 7, + type: 'number' } + }; + assert.deepEqual(layergroup.metadata.layers[0].meta.stats.dimensions, expectedDimensions); + }); + }); ['centroid', 'point-sample', 'point-grid'].forEach(placement => { it(`dimensions should work for ${placement} placement`, function(done) {