torque/test/provider.json.js

49 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2013-10-10 16:59:19 +08:00
2013-10-15 16:40:31 +08:00
var json, url;
module('provider.json')
QUnit.testStart(function() {
json = new torque.providers.json({
2013-10-17 21:51:12 +08:00
table: 'test',
user: "rambo",
2013-10-10 16:59:19 +08:00
resolution: 1,
2013-10-15 16:40:31 +08:00
steps: 10,
extra_params: {
testing: 'abcd%'
}
2013-10-10 16:59:19 +08:00
});
2013-10-15 16:40:31 +08:00
});
test("url", function() {
2013-10-10 16:59:19 +08:00
equal("http://rambo.cartodb.com/api/v2/sql", json.url());
});
2013-10-15 16:40:31 +08:00
test("extra_params", function() {
var url = "http://rambo.cartodb.com/api/v2/sql?q=1&testing=abcd%25";
json.sql('1');
equal(torque.net.lastCall().url, url);
});
2013-11-09 00:09:19 +08:00
test("no_cdn", function() {
var url = "http://rambo.cartodb.com/api/v2/sql?q=1&testing=abcd%25";
json.options.cdn_url = 'test-cdn.com'
json.sql('1', null, { no_cdn: true });
equal(torque.net.lastCall().url, url);
});
2013-10-17 21:51:12 +08:00
test("getSQL", function() {
var s;
equal(json.getSQL(), "select * from test");
json.setSQL(s='select * from test limit 10');
equal(json.getSQL(), s);
json.setSQL(null);
equal(json.getSQL(), "select * from test");
});
2013-11-01 02:07:27 +08:00
test("cdn_url", function() {
json.options.cdn_url = { http: 'test.com' };
2013-11-09 00:09:19 +08:00
equal(json.url('a'), 'http://a.test.com/rambo/api/v2/sql');
2013-11-01 02:07:27 +08:00
});
2013-10-10 16:59:19 +08:00