Add test to check if NULL category count values properly
This commit is contained in:
parent
2598595e42
commit
f5f0601e53
@ -13,8 +13,11 @@ describe('aggregations', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function aggregationOperationMapConfig(operation) {
|
function aggregationOperationMapConfig(operation, column, aggregationColumn) {
|
||||||
return {
|
column = column || 'adm0name';
|
||||||
|
aggregationColumn = aggregationColumn || 'pop_max';
|
||||||
|
|
||||||
|
var mapConfig = {
|
||||||
version: '1.5.0',
|
version: '1.5.0',
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
@ -23,20 +26,22 @@ describe('aggregations', function() {
|
|||||||
sql: 'select * from populated_places_simple_reduced',
|
sql: 'select * from populated_places_simple_reduced',
|
||||||
cartocss: '#layer0 { marker-fill: red; marker-width: 10; }',
|
cartocss: '#layer0 { marker-fill: red; marker-width: 10; }',
|
||||||
cartocss_version: '2.0.1',
|
cartocss_version: '2.0.1',
|
||||||
widgets: {
|
widgets: {}
|
||||||
adm0name: {
|
|
||||||
type: 'aggregation',
|
|
||||||
options: {
|
|
||||||
column: 'adm0name',
|
|
||||||
aggregation: operation,
|
|
||||||
aggregationColumn: 'pop_max'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mapConfig.layers[0].options.widgets[column] = {
|
||||||
|
type: 'aggregation',
|
||||||
|
options: {
|
||||||
|
column: column,
|
||||||
|
aggregation: operation,
|
||||||
|
aggregationColumn: aggregationColumn
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return mapConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
var operations = ['count', 'sum', 'avg', 'max', 'min'];
|
var operations = ['count', 'sum', 'avg', 'max', 'min'];
|
||||||
@ -56,4 +61,26 @@ describe('aggregations', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should count NULL category', function (done) {
|
||||||
|
this.testClient = new TestClient(aggregationOperationMapConfig('count', 'namepar'));
|
||||||
|
this.testClient.getDataview('namepar', { own_filter: 0 }, function (err, aggregation) {
|
||||||
|
assert.ifError(err);
|
||||||
|
|
||||||
|
assert.ok(aggregation);
|
||||||
|
assert.equal(aggregation.type, 'aggregation');
|
||||||
|
assert.ok(aggregation.categories);
|
||||||
|
|
||||||
|
var hasNullCategory = false;
|
||||||
|
aggregation.categories.forEach(function (category) {
|
||||||
|
if (category.category === null) {
|
||||||
|
assert.ok(category.value > 0);
|
||||||
|
hasNullCategory = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assert.ok(hasNullCategory, 'there is no category NULL');
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user