Browse Source

added unit tests for verifying valid mapping between sources and layers

pull/313/head
Stephen Hess 9 years ago
parent
commit
02792de2dc
  1. 91
      test/unit/helper/type_mapping.js

91
test/unit/helper/type_mapping.js

@ -39,6 +39,97 @@ module.exports.tests.interfaces = function(test, common) {
t.ok(check.hasLength(Object.keys(type_mapping.layer_with_aliases_to_type), 9), 'has correct number of elements'); t.ok(check.hasLength(Object.keys(type_mapping.layer_with_aliases_to_type), 9), 'has correct number of elements');
t.end(); t.end();
}); });
test('\'osm\' and \'openstreetmap\' sources should only successfully map to \'venue\' and \'address\' layers', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'venue'), ['osmnode', 'osmway']);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'address'), ['osmaddress']);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('osm', 'coarse'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'venue'), ['osmnode', 'osmway']);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'address'), ['osmaddress']);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openstreetmap', 'coarse'), []);
t.end();
});
test('\'gn\' and \'geonames\' sources should only successfully map to a subset of layers', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'venue'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'address'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'country'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'region'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'county'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'locality'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'neighbourhood'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('gn', 'coarse'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'venue'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'address'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'country'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'region'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'county'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'locality'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'neighbourhood'), ['geoname']);
t.deepEquals(type_mapping.source_and_layer_to_type('geonames', 'coarse'), []);
t.end();
});
test('\'oa\' and \'openaddresses\' sources should only successfully map to \'address\' layer', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'address'), ['openaddresses']);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('oa', 'coarse'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'address'), ['openaddresses']);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'country'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'region'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'county'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'locality'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'localadmin'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'neighbourhood'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('openaddresses', 'coarse'), []);
t.end();
});
test('\'qs\' and \'quattroshapes\' sources should only successfully map to \'address\' layer', function(t) {
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'address'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'country'), ['admin0']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'region'), ['admin1']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'county'), ['admin2']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'locality'), ['locality']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'localadmin'), ['local_admin']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'neighbourhood'), ['neighborhood']);
t.deepEquals(type_mapping.source_and_layer_to_type('qs', 'coarse'),
['admin0','admin1','admin2','neighborhood','locality','local_admin']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'venue'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'address'), []);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'country'), ['admin0']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'region'), ['admin1']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'county'), ['admin2']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'locality'), ['locality']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'localadmin'), ['local_admin']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'neighbourhood'), ['neighborhood']);
t.deepEquals(type_mapping.source_and_layer_to_type('quattroshapes', 'coarse'),
['admin0','admin1','admin2','neighborhood','locality','local_admin']);
t.end();
});
}; };
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {

Loading…
Cancel
Save