2014-02-04 00:38:05 +08:00
|
|
|
var windshaft, url;
|
|
|
|
var lastCall;
|
|
|
|
var old_net;
|
|
|
|
module('provider.windshaft', {
|
|
|
|
setup: function() {
|
2014-02-05 01:13:34 +08:00
|
|
|
old_net = torque.net.jsonp;
|
|
|
|
old_get = torque.net.get;
|
|
|
|
torque.net.jsonp = function(url, callback) {
|
|
|
|
lastCall = url;
|
|
|
|
callback({ layergroupid: 'testlg', metadata: { torque: { 0: { data_steps:10 }} } });
|
|
|
|
};
|
2014-02-04 00:38:05 +08:00
|
|
|
torque.net.get = function(url, callback) {
|
|
|
|
lastCall = url;
|
2014-02-05 01:13:34 +08:00
|
|
|
callback(null);
|
2014-02-04 00:38:05 +08:00
|
|
|
};
|
|
|
|
windshaft = new torque.providers.windshaft({
|
|
|
|
table: 'test',
|
|
|
|
user: "rambo",
|
|
|
|
cartocss: '#test{}',
|
|
|
|
sql: 'test',
|
|
|
|
resolution: 1,
|
|
|
|
steps: 10,
|
|
|
|
extra_params: {
|
|
|
|
testing: 'abcd%'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
teardown: function() {
|
2014-02-05 01:13:34 +08:00
|
|
|
torque.net.jsonp = old_net;
|
|
|
|
torque.net.get = old_get;
|
2014-02-04 00:38:05 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test("tiler request", function() {
|
|
|
|
var layergroup = {
|
|
|
|
"version": "1.0.1",
|
|
|
|
"stat_tag": 'torque',
|
|
|
|
"layers": [{
|
|
|
|
"type": "torque",
|
|
|
|
"options": {
|
|
|
|
"cartocss_version": "2.1.1",
|
|
|
|
"cartocss": '#test{}',
|
|
|
|
"sql": 'test'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2014-02-06 21:25:47 +08:00
|
|
|
var url = "http://rambo.cartodb.com:80/api/v1/map?config=" + encodeURIComponent(JSON.stringify(layergroup)) + "&callback="
|
2014-02-04 00:38:05 +08:00
|
|
|
equal(lastCall.indexOf(url), 0);
|
2014-02-05 01:13:34 +08:00
|
|
|
equal(windshaft.options.data_steps, 10);
|
|
|
|
|
2014-02-04 00:38:05 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test("url", function() {
|
|
|
|
equal(windshaft.url(), "http://rambo.cartodb.com:80");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("url cdn", function() {
|
|
|
|
windshaft.options.cdn_url = { http: 'cartocdn.com' };
|
|
|
|
equal(windshaft.url(), "http://{s}.cartocdn.com/rambo");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("named map", function() {
|
|
|
|
windshaft_named = new torque.providers.windshaft({
|
|
|
|
table: 'test',
|
|
|
|
user: "rambo",
|
|
|
|
named_map: {
|
|
|
|
name: 'test_named'
|
|
|
|
}
|
|
|
|
});
|
2014-02-06 21:25:47 +08:00
|
|
|
var url = "http://rambo.cartodb.com:80/api/v1/map/named/test_named/jsonp?config";
|
2014-02-04 00:38:05 +08:00
|
|
|
equal(lastCall.indexOf(url), 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("fetch tile", function() {
|
|
|
|
windshaft._ready = true;
|
|
|
|
windshaft.getTileData({x: 0, y: 1}, 2, function() {});
|
2014-02-06 21:25:47 +08:00
|
|
|
equal(lastCall,"http://rambo.cartodb.com:80/api/v1/map/testlg/0/2/0/1.json.torque?testing=abcd%25");
|
2014-02-04 00:38:05 +08:00
|
|
|
});
|
|
|
|
|
2014-02-06 21:25:47 +08:00
|
|
|
test("include auth_token", function() {
|
|
|
|
windshaft_named = new torque.providers.windshaft({
|
|
|
|
table: 'test',
|
|
|
|
user: "rambo",
|
|
|
|
auth_token: 'test_auth_token',
|
|
|
|
named_map: {
|
|
|
|
name: 'test_named'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
ok(lastCall.indexOf("auth_token=test_auth_token") !== -1);
|
|
|
|
})
|
|
|
|
|
2014-02-04 00:38:05 +08:00
|
|
|
|
|
|
|
|