2017-07-18 01:43:59 +08:00
|
|
|
require('../support/test_helper');
|
|
|
|
|
2017-07-18 16:44:27 +08:00
|
|
|
const assert = require('../support/assert');
|
|
|
|
const TestClient = require('../support/test-client');
|
2017-07-18 01:43:59 +08:00
|
|
|
|
2017-07-18 16:44:27 +08:00
|
|
|
function createMapConfig (sql = TestClient.SQL.ONE_POINT) {
|
2017-07-18 01:43:59 +08:00
|
|
|
return {
|
|
|
|
version: '1.6.0',
|
|
|
|
layers: [{
|
|
|
|
type: "cartodb",
|
|
|
|
options: {
|
|
|
|
sql: sql,
|
|
|
|
cartocss: TestClient.CARTOCSS.POINTS,
|
|
|
|
cartocss_version: '2.3.0',
|
|
|
|
interactivity: 'cartodb_id'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('mvt', function () {
|
|
|
|
const testCases = [
|
|
|
|
{
|
|
|
|
desc: 'should get empty mvt with code 204 (no content)',
|
|
|
|
coords: { z: 0, x: 0, y: 0 },
|
|
|
|
format: 'mvt',
|
2017-07-31 23:58:33 +08:00
|
|
|
response: {
|
|
|
|
status: 204,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': undefined
|
|
|
|
}
|
|
|
|
},
|
2017-07-18 16:44:27 +08:00
|
|
|
mapConfig: createMapConfig(TestClient.SQL.EMPTY)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: 'should get mvt tile with code 200 (ok)',
|
|
|
|
coords: { z: 0, x: 0, y: 0 },
|
|
|
|
format: 'mvt',
|
2017-07-31 23:58:33 +08:00
|
|
|
response: {
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-protobuf'
|
|
|
|
}
|
|
|
|
},
|
2017-07-18 16:44:27 +08:00
|
|
|
mapConfig: createMapConfig()
|
2017-07-18 01:43:59 +08:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
testCases.forEach(function (test) {
|
|
|
|
it(test.desc, done => {
|
|
|
|
const testClient = new TestClient(test.mapConfig, 1234);
|
|
|
|
const { z, x, y } = test.coords;
|
2017-07-31 23:58:33 +08:00
|
|
|
const { format, response } = test;
|
2017-07-18 01:43:59 +08:00
|
|
|
|
2017-07-31 23:58:33 +08:00
|
|
|
testClient.getTile(z, x, y, { format, response }, (err, res) => {
|
2017-07-18 01:43:59 +08:00
|
|
|
assert.ifError(err);
|
|
|
|
|
2017-07-31 23:58:33 +08:00
|
|
|
assert.equal(res.statusCode, test.response.status);
|
2017-07-18 01:43:59 +08:00
|
|
|
testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-07-18 17:05:45 +08:00
|
|
|
});
|