Browse Source

set req.clean.parser to 'libpostal' when it's called

pull/1017/head
Stephen Hess 7 years ago
parent
commit
da07463999
  1. 1
      controller/libpostal.js
  2. 4
      test/unit/controller/libpostal.js

1
controller/libpostal.js

@ -20,6 +20,7 @@ function setup(should_execute) {
parsed_text.country = iso3166.to3(_.toUpper(parsed_text.country)); parsed_text.country = iso3166.to3(_.toUpper(parsed_text.country));
} }
req.clean.parser = 'libpostal';
req.clean.parsed_text = parsed_text; req.clean.parsed_text = parsed_text;
debugLog.push(req, {parsed_text: req.clean.parsed_text}); debugLog.push(req, {parsed_text: req.clean.parsed_text});
} }

4
test/unit/controller/libpostal.js

@ -149,6 +149,7 @@ module.exports.tests.parse_is_called = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
t.deepEquals(req, { t.deepEquals(req, {
clean: { clean: {
parser: 'libpostal',
parsed_text: 'replacement parsed_text' parsed_text: 'replacement parsed_text'
} }
}); });
@ -184,6 +185,7 @@ module.exports.tests.iso2_conversion = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
t.deepEquals(req, { t.deepEquals(req, {
clean: { clean: {
parser: 'libpostal',
parsed_text: { parsed_text: {
locality: 'this is the locality' locality: 'this is the locality'
} }
@ -223,6 +225,7 @@ module.exports.tests.iso2_conversion = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
t.deepEquals(req, { t.deepEquals(req, {
clean: { clean: {
parser: 'libpostal',
parsed_text: { parsed_text: {
country: 'unknown country code' country: 'unknown country code'
} }
@ -265,6 +268,7 @@ module.exports.tests.iso2_conversion = (test, common) => {
controller(req, res, () => { controller(req, res, () => {
t.deepEquals(req, { t.deepEquals(req, {
clean: { clean: {
parser: 'libpostal',
parsed_text: { parsed_text: {
country: 'ISO3 COUNTRY CODE' country: 'ISO3 COUNTRY CODE'
} }

Loading…
Cancel
Save