From b5b8647f0c849c9f7f3ac57cdf2759c9317153aa Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 8 Oct 2015 10:47:45 +0200 Subject: [PATCH] more label improvements --- helper/labelSchema.json | 10 ++-- test/unit/helper/labelGenerator.js | 77 +++++++++++++++++++++++++++++- test/unit/helper/labelSchema.js | 12 ++--- 3 files changed, 89 insertions(+), 10 deletions(-) diff --git a/helper/labelSchema.json b/helper/labelSchema.json index 49c96017..4b555790 100644 --- a/helper/labelSchema.json +++ b/helper/labelSchema.json @@ -11,8 +11,12 @@ "local": ["neighbourhood", "region", "county", "localadmin", "locality"], "regional": ["county","country","region"] }, + "SWE": { + "local": ["neighbourhood", "region", "county", "localadmin", "locality"], + "regional": ["country"] + }, "default": { - "local": ["localadmin", "locality", "neighbourhood", "county"], - "regional": ["region_a", "region", "country"] + "local": ["localadmin", "locality", "neighbourhood", "county", "region"], + "regional": ["country"] } -} \ No newline at end of file +} diff --git a/test/unit/helper/labelGenerator.js b/test/unit/helper/labelGenerator.js index e1bf0da3..e295c160 100644 --- a/test/unit/helper/labelGenerator.js +++ b/test/unit/helper/labelGenerator.js @@ -92,6 +92,22 @@ module.exports.tests.west_bengal = function(test, common) { }); }; +// IND city +module.exports.tests.bangalore = function(test, common) { + test('bangalore', function(t) { + var doc = { + 'name': { 'default': 'Bangalore' }, + 'country_a': 'IND', + 'country': 'India', + 'region': 'Karnataka', + 'county': 'Bangalore', + 'locality': 'Bangalore' + }; + t.equal(generator(doc),'Bangalore, Karnataka, India'); + t.end(); + }); +}; + // SGP region module.exports.tests.north_west_singapore = function(test, common) { test('north west singapore', function(t) { @@ -134,6 +150,37 @@ module.exports.tests.madrid = function(test, common) { }); }; +// SWE city +module.exports.tests.skane1 = function(test, common) { + test('skåne 1', function(t) { + var doc = { + 'name': { 'default': 'Malmö' }, + 'country_a': 'SWE', + 'country': 'Sweden', + 'region': 'Skåne', + 'county': 'Malmö' + }; + t.equal(generator(doc),'Malmö, Skåne, Sweden'); + t.end(); + }); +}; + +// SWE city +module.exports.tests.skane2 = function(test, common) { + test('skåne 2', function(t) { + var doc = { + 'name': { 'default': 'Malmö' }, + 'country_a': 'SWE', + 'country': 'Sweden', + 'region': 'Skåne', + 'county': 'Malmö', + 'locality': 'Malmö' + }; + t.equal(generator(doc),'Malmö, Skåne, Sweden'); + t.end(); + }); +}; + // GBR street address module.exports.tests.one_main_street_uk = function(test, common) { test('one main street uk', function(t) { @@ -201,6 +248,34 @@ module.exports.tests.new_zealand = function(test, common) { }); }; +// GBR country +module.exports.tests.wales = function(test, common) { + test('wales', function(t) { + var doc = { + 'name': { 'default': 'Wales' }, + 'country_a': 'GBR', + 'country': 'United Kingdom', + 'region': 'Wales' + }; + t.equal(generator(doc),'Wales, United Kingdom'); + t.end(); + }); +}; + +// IRL country +module.exports.tests.republic_of_ireland = function(test, common) { + test('northern ireland', function(t) { + var doc = { + 'name': { 'default': 'Ireland' }, + 'country_a': 'IRL', + 'country': 'Ireland' + }; + // !! this is not part of the UK !! + t.equal(generator(doc),'Ireland'); + t.end(); + }); +}; + // SGP venue module.exports.tests.singapore_mcdonalds = function(test, common) { test('singapore_mcdonalds', function(t) { @@ -225,4 +300,4 @@ module.exports.all = function (tape, common) { for( var testCase in module.exports.tests ){ module.exports.tests[testCase](test, common); } -}; \ No newline at end of file +}; diff --git a/test/unit/helper/labelSchema.js b/test/unit/helper/labelSchema.js index f85c43aa..dcc3cdfa 100644 --- a/test/unit/helper/labelSchema.js +++ b/test/unit/helper/labelSchema.js @@ -15,16 +15,16 @@ module.exports.tests.interface = function(test, common) { module.exports.tests.valid = function(test, common) { var valid_keys = ['localadmin', 'locality', 'neighbourhood', 'county', 'region_a', 'region', 'country']; var default_schema = { - local: ['localadmin', 'locality', 'neighbourhood', 'county'], - regional: ['region_a', 'region', 'country'] + local: ['localadmin', 'locality', 'neighbourhood', 'county', 'region'], + regional: ['country'] }; var isValid = function(keys, schema) { test('valid key/object (' + keys + ')' , function(t) { - if (keys === 'default') { + if (keys === 'default') { t.deepEqual(schema, default_schema, 'valid default schema'); } else { - t.equal(alpha3.hasOwnProperty(keys), true, 'valid key'); + t.equal(alpha3.hasOwnProperty(keys), true, 'valid key'); } t.equal(typeof schema, 'object', 'valid object'); t.notEqual(Object.getOwnPropertyNames(schema).length, 0, 'object not empty'); @@ -39,7 +39,7 @@ module.exports.tests.valid = function(test, common) { }); }; - for (var keys in schemas) { + for (var keys in schemas) { isValid(keys, schemas[keys]); } }; @@ -53,4 +53,4 @@ module.exports.all = function (tape, common) { for( var testCase in module.exports.tests ){ module.exports.tests[testCase](test, common); } -}; \ No newline at end of file +};