Browse Source

support aliases for label generation

pull/1102/head
missinglink 7 years ago
parent
commit
e01fdb85c9
  1. 2
      middleware/assignLabels.js
  2. 2
      package.json
  3. 27
      test/unit/middleware/assignLabels.js

2
middleware/assignLabels.js

@ -1,4 +1,4 @@
var defaultLabelGenerator = require('pelias-labels'); const defaultLabelGenerator = require('pelias-labels');
function setup(labelGenerator) { function setup(labelGenerator) {
function middleware(req, res, next) { function middleware(req, res, next) {

2
package.json

@ -56,7 +56,7 @@
"morgan": "^1.8.2", "morgan": "^1.8.2",
"pelias-categories": "1.2.0", "pelias-categories": "1.2.0",
"pelias-config": "2.14.0", "pelias-config": "2.14.0",
"pelias-labels": "1.7.0", "pelias-labels": "1.8.0",
"pelias-logger": "0.3.1", "pelias-logger": "0.3.1",
"pelias-microservice-wrapper": "1.3.0", "pelias-microservice-wrapper": "1.3.0",
"pelias-model": "5.3.2", "pelias-model": "5.3.2",

27
test/unit/middleware/assignLabels.js

@ -104,6 +104,33 @@ module.exports.tests.serialization = function(test, common) {
}); });
test('support name aliases', function(t) {
var assignLabels = require('../../../middleware/assignLabels')();
var res = {
data: [{
name: {
default: ['name1','name2']
}
}]
};
var expected = {
data: [{
name: {
default: ['name1','name2']
},
label: 'name1'
}]
};
assignLabels({}, res, function () {
t.deepEqual(res, expected);
t.end();
});
});
}; };
module.exports.all = function (tape, common) { module.exports.all = function (tape, common) {

Loading…
Cancel
Save