From ff5c66a269bd37f32e779e1fde5672f4b099c9cc Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 11 Oct 2018 12:35:55 -0400 Subject: [PATCH] fix(test): Use default pelias-config for type tests Without this change, a user's own `pelias.json` customizations can cause the unit tests to fail. --- helper/type_mapping.js | 2 +- test/unit/helper/type_mapping.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/helper/type_mapping.js b/helper/type_mapping.js index 987aa26a..2e97231c 100644 --- a/helper/type_mapping.js +++ b/helper/type_mapping.js @@ -5,4 +5,4 @@ var tm = new TypeMapping(); tm.load(); // export singleton -module.exports = tm; \ No newline at end of file +module.exports = tm; diff --git a/test/unit/helper/type_mapping.js b/test/unit/helper/type_mapping.js index f66cef88..cc984ec5 100644 --- a/test/unit/helper/type_mapping.js +++ b/test/unit/helper/type_mapping.js @@ -1,4 +1,20 @@ -var type_mapping = require('../../../helper/type_mapping'); +const proxyquire = require('proxyquire').noCallThru(); + +const realPeliasConfig = require('pelias-config'); + +const defaultPeliasConfig = { + generate: function() { + return realPeliasConfig.defaults; + } +}; + +// test the actual module, rather than the singleton wrapper +var TypeMapping = proxyquire('../../../helper/TypeMapping', { + 'pelias-config': defaultPeliasConfig +}); + +const type_mapping = new TypeMapping(); +type_mapping.load(); module.exports.tests = {};