diff --git a/service/configurations/Language.js b/service/configurations/Language.js index c20fa861..a4d96c96 100644 --- a/service/configurations/Language.js +++ b/service/configurations/Language.js @@ -15,12 +15,18 @@ class Language extends ServiceConfiguration { Array.prototype.push.apply(acc, _.values(_.pickBy(doc.parent, (v, k) => _.endsWith(k, '_id') ) ) ); return acc; }, []); - - return { + const lang = _.get(req, 'clean.lang.iso6393'); + const parameters = { // arrays will be nested, so flatten first, then uniqify, and finally join elements with comma ids: _.uniq(_.flattenDeep(ids)).join(',') }; + if (lang) { + parameters.lang = lang; + } + + return parameters; + } getUrl(req) { diff --git a/test/unit/service/configurations/Language.js b/test/unit/service/configurations/Language.js index 72cfb7d3..682ddc0a 100644 --- a/test/unit/service/configurations/Language.js +++ b/test/unit/service/configurations/Language.js @@ -117,6 +117,24 @@ module.exports.tests.all = (test, common) => { }); + + test('getParameters should return lang when req.clean.lang.iso6393 is defined', (t) => { + const configBlob = { + url: 'http://localhost:1234', + timeout: 17, + retries: 19 + }; + + const req = {clean: {lang: {iso6393: 'eng' }}}; + const res = { }; + + const language = new Language(configBlob); + + t.deepEquals(language.getParameters(req, res), { ids: '', lang: 'eng' }); + t.end(); + + }); + test('getHeaders should return empty object', (t) => { const configBlob = { url: 'base url',