From 54f32113f348d7fa0d0deb84b27f7d21928ba968 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Fri, 22 Dec 2017 15:45:34 +0100 Subject: [PATCH] Add some aggregation tests --- test/acceptance/aggregation.js | 50 +++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 1809c8a0..afc27282 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -697,7 +697,7 @@ describe('aggregation', function () { }); }); - it(`aggregations should trigger non-default aggregation`, function(done) { + it(`aggregation columns should trigger non-default aggregation`, function(done) { // FIXME: skip until pg-mvt renderer is able to return all columns if (process.env.POSTGIS_VERSION === '2.4') { @@ -743,6 +743,54 @@ describe('aggregation', function () { done(); }); }); + + ['centroid', 'point-sample', 'point-grid'].forEach(placement => { + it(`aggregations with base column names should work for ${placement} placement`, function(done) { + + // FIXME: skip until pg-mvt renderer is able to return all columns + if (process.env.POSTGIS_VERSION === '2.4') { + return done(); + } + + this.mapConfig = createVectorMapConfig([ + { + type: 'cartodb', + options: { + sql: POINTS_SQL_1, + aggregation: { + placement: placement , + threshold: 1, + columns: { + value: { + aggregate_function: 'sum', + aggregated_column: 'value' + } + } + } + } + } + ]); + + this.testClient = new TestClient(this.mapConfig); + const options = { + format: 'mvt' + }; + this.testClient.getTile(0, 0, 0, options, (err, res, tile) => { + if (err) { + return done(err); + } + + const tileJSON = tile.toJSON(); + + tileJSON[0].features.forEach( + feature => assert.equal(typeof feature.properties.value, 'number') + ); + + done(); + }); + }); + }); + it('should work when the sql has single quotes', function (done) { this.mapConfig = createVectorMapConfig([ {