Browse Source

more label improvements

pull/340/head
Peter Johnson 9 years ago
parent
commit
b5b8647f0c
  1. 10
      helper/labelSchema.json
  2. 77
      test/unit/helper/labelGenerator.js
  3. 12
      test/unit/helper/labelSchema.js

10
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"]
}
}
}

77
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);
}
};
};

12
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);
}
};
};

Loading…
Cancel
Save