|
|
@ -10,6 +10,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.equal(messages.errors.length, 0, 'no errors'); |
|
|
|
t.equal(messages.errors.length, 0, 'no errors'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('invalid layer', function(t) { |
|
|
|
test('invalid layer', function(t) { |
|
|
|
var raw = { layers: 'test_layer' }; |
|
|
|
var raw = { layers: 'test_layer' }; |
|
|
|
var clean = {}; |
|
|
|
var clean = {}; |
|
|
@ -22,6 +23,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.true(messages.errors[0].length > msg.length, 'invalid error message'); |
|
|
|
t.true(messages.errors[0].length > msg.length, 'invalid error message'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('venue (alias) layer', function(t) { |
|
|
|
test('venue (alias) layer', function(t) { |
|
|
|
var venue_layers = ['geoname','osmnode','osmway']; |
|
|
|
var venue_layers = ['geoname','osmnode','osmway']; |
|
|
|
var raw = { layers: 'venue' }; |
|
|
|
var raw = { layers: 'venue' }; |
|
|
@ -32,6 +34,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, venue_layers, 'venue layers set'); |
|
|
|
t.deepEqual(clean.types.from_layers, venue_layers, 'venue layers set'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('coarse (alias) layer', function(t) { |
|
|
|
test('coarse (alias) layer', function(t) { |
|
|
|
var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin']; |
|
|
|
var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin']; |
|
|
|
var raw = { layers: 'coarse' }; |
|
|
|
var raw = { layers: 'coarse' }; |
|
|
@ -42,6 +45,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, admin_layers, 'coarse layers set'); |
|
|
|
t.deepEqual(clean.types.from_layers, admin_layers, 'coarse layers set'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('address (alias) layer', function(t) { |
|
|
|
test('address (alias) layer', function(t) { |
|
|
|
var address_layers = ['osmaddress','openaddresses']; |
|
|
|
var address_layers = ['osmaddress','openaddresses']; |
|
|
|
var raw = { layers: 'address' }; |
|
|
|
var raw = { layers: 'address' }; |
|
|
@ -52,6 +56,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, address_layers, 'address layers set'); |
|
|
|
t.deepEqual(clean.types.from_layers, address_layers, 'address layers set'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('venue alias layer plus regular layers', function(t) { |
|
|
|
test('venue alias layer plus regular layers', function(t) { |
|
|
|
var venue_layers = ['geoname','osmnode','osmway']; |
|
|
|
var venue_layers = ['geoname','osmnode','osmway']; |
|
|
|
var reg_layers = ['admin0', 'admin1']; |
|
|
|
var reg_layers = ['admin0', 'admin1']; |
|
|
@ -63,6 +68,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, venue_layers.concat(reg_layers), 'venue + regular layers'); |
|
|
|
t.deepEqual(clean.types.from_layers, venue_layers.concat(reg_layers), 'venue + regular layers'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('coarse alias layer plus regular layers', function(t) { |
|
|
|
test('coarse alias layer plus regular layers', function(t) { |
|
|
|
var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin']; |
|
|
|
var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin']; |
|
|
|
var reg_layers = ['geoname', 'osmnode', 'osmway']; |
|
|
|
var reg_layers = ['geoname', 'osmnode', 'osmway']; |
|
|
@ -75,6 +81,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, admin_layers.concat(reg_layers), 'coarse + regular layers set'); |
|
|
|
t.deepEqual(clean.types.from_layers, admin_layers.concat(reg_layers), 'coarse + regular layers set'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('address alias layer plus regular layers', function(t) { |
|
|
|
test('address alias layer plus regular layers', function(t) { |
|
|
|
var address_layers = ['osmaddress','openaddresses']; |
|
|
|
var address_layers = ['osmaddress','openaddresses']; |
|
|
|
var reg_layers = ['admin0', 'locality']; |
|
|
|
var reg_layers = ['admin0', 'locality']; |
|
|
@ -87,6 +94,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, address_layers.concat(reg_layers), 'address + regular layers set'); |
|
|
|
t.deepEqual(clean.types.from_layers, address_layers.concat(reg_layers), 'address + regular layers set'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('alias layer plus regular layers (no duplicates)', function(t) { |
|
|
|
test('alias layer plus regular layers (no duplicates)', function(t) { |
|
|
|
var venue_layers = ['geoname','osmnode','osmway','admin0']; |
|
|
|
var venue_layers = ['geoname','osmnode','osmway','admin0']; |
|
|
|
var raw = { layers: 'venue,country' }; |
|
|
|
var raw = { layers: 'venue,country' }; |
|
|
@ -97,6 +105,7 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
t.deepEqual(clean.types.from_layers, venue_layers, 'venue layers found (no duplicates)'); |
|
|
|
t.deepEqual(clean.types.from_layers, venue_layers, 'venue layers found (no duplicates)'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('multiple alias layers (no duplicates)', function(t) { |
|
|
|
test('multiple alias layers (no duplicates)', function(t) { |
|
|
|
var alias_layers = ['geoname','osmnode','osmway','admin0','admin1','admin2','neighborhood','locality','local_admin']; |
|
|
|
var alias_layers = ['geoname','osmnode','osmway','admin0','admin1','admin2','neighborhood','locality','local_admin']; |
|
|
|
var raw = { layers: 'venue,coarse' }; |
|
|
|
var raw = { layers: 'venue,coarse' }; |
|
|
@ -110,7 +119,6 @@ module.exports.tests.sanitize_layers = function(test, common) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
module.exports.all = function (tape, common) { |
|
|
|
module.exports.all = function (tape, common) { |
|
|
|
|
|
|
|
|
|
|
|
function test(name, testFunction) { |
|
|
|
function test(name, testFunction) { |
|
|
|
return tape('SANTIZE _layers ' + name, testFunction); |
|
|
|
return tape('SANTIZE _layers ' + name, testFunction); |
|
|
|
} |
|
|
|
} |
|
|
|