CartoDB-SQL-API/test/acceptance/export/arraybuffer.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-10-24 21:42:33 +08:00
'use strict';
2013-05-17 17:44:50 +08:00
require('../../helper');
require('../../support/assert');
var server = require('../../../app/server')();
2015-05-13 17:53:14 +08:00
var assert = require('assert');
var querystring = require('querystring');
2013-05-17 17:44:50 +08:00
2015-05-13 17:53:14 +08:00
describe('export.arraybuffer', function() {
2013-05-17 17:44:50 +08:00
2015-05-13 17:53:14 +08:00
it('GET /api/v1/sql as arraybuffer ', function(done){
assert.response(server, {
2013-05-17 17:44:50 +08:00
url: '/api/v1/sql?' + querystring.stringify({
q: 'SELECT cartodb_id,name,1::integer,187.9 FROM untitle_table_4',
format: 'arraybuffer'
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(err, res){
2013-05-17 17:44:50 +08:00
assert.equal(res.statusCode, 200, res.body);
2015-05-13 17:53:14 +08:00
assert.equal(res.headers['content-type'], "application/octet-stream");
2013-05-17 17:44:50 +08:00
done();
});
});
2015-05-13 17:53:14 +08:00
it('GET /api/v1/sql as arraybuffer does not support geometry types ', function(done){
assert.response(server, {
2013-05-17 17:44:50 +08:00
url: '/api/v1/sql?' + querystring.stringify({
q: 'SELECT cartodb_id, the_geom FROM untitle_table_4',
format: 'arraybuffer'
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(err, res){
2013-05-17 17:44:50 +08:00
assert.equal(res.statusCode, 400, res.body);
var result = JSON.parse(res.body);
assert.equal(result.error[0], "geometry types are not supported");
done();
});
});
});