2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../support/test-helper');
|
2017-06-27 17:21:05 +08:00
|
|
|
|
|
|
|
var assert = require('../support/assert');
|
|
|
|
var TestClient = require('../support/test-client');
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('special numeric values', function () {
|
|
|
|
afterEach(function (done) {
|
2017-06-27 17:21:05 +08:00
|
|
|
if (this.testClient) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
} else {
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var ATTRIBUTES_LAYER = 1;
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
function createMapConfig (sql, id, columns) {
|
2017-06-27 17:21:05 +08:00
|
|
|
return {
|
|
|
|
version: '1.6.0',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
type: 'mapnik',
|
|
|
|
options: {
|
|
|
|
sql: "select 1 as id, 'SRID=4326;POINT(0 0)'::geometry as the_geom",
|
|
|
|
cartocss: '#style { }',
|
|
|
|
cartocss_version: '2.0.1'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'mapnik',
|
|
|
|
options: {
|
|
|
|
sql: sql || "select 1 as i, 6 as n, 'SRID=4326;POINT(0 0)'::geometry as the_geom",
|
|
|
|
attributes: {
|
|
|
|
id: id || 'i',
|
|
|
|
columns: columns || ['n']
|
|
|
|
},
|
|
|
|
cartocss: '#style { }',
|
|
|
|
cartocss_version: '2.0.1'
|
|
|
|
}
|
|
|
|
}
|
2019-10-22 01:07:24 +08:00
|
|
|
]
|
2017-06-27 17:21:05 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
it('should retrieve special numeric values', function (done) {
|
|
|
|
var featureId = 1;
|
|
|
|
var sql = [
|
|
|
|
'SELECT',
|
|
|
|
' 1 as cartodb_id,',
|
|
|
|
' null::geometry the_geom_webmercator,',
|
|
|
|
' \'infinity\'::float as infinity,',
|
|
|
|
' \'-infinity\'::float as _infinity,',
|
|
|
|
' \'NaN\'::float as nan'
|
|
|
|
].join('\n');
|
|
|
|
var id = 'cartodb_id';
|
|
|
|
var columns = ['infinity', '_infinity', 'nan'];
|
|
|
|
|
|
|
|
var mapConfig = createMapConfig(sql, id, columns);
|
|
|
|
|
|
|
|
this.testClient = new TestClient(mapConfig, 1234);
|
|
|
|
this.testClient.getFeatureAttributes(featureId, ATTRIBUTES_LAYER, {}, function (err, attributes) {
|
|
|
|
assert.ifError(err);
|
2019-10-22 01:41:03 +08:00
|
|
|
assert.strictEqual(attributes.infinity, 'Infinity');
|
|
|
|
assert.strictEqual(attributes._infinity, '-Infinity');
|
|
|
|
assert.strictEqual(attributes.nan, 'NaN');
|
2017-06-27 17:21:05 +08:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|