From eabbd17f1ca414f95ca61faac077ae1a9035780e Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 24 Oct 2018 10:21:07 +0200 Subject: [PATCH] testing: add test case: incorrect parsing of diagonal directionals - no subsequent element --- test/unit/controller/libpostal.js | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/unit/controller/libpostal.js b/test/unit/controller/libpostal.js index 129cce4a..cc24b564 100644 --- a/test/unit/controller/libpostal.js +++ b/test/unit/controller/libpostal.js @@ -357,6 +357,49 @@ module.exports.tests.bug_fixes = (test, common) => { }); + test('bug fix: incorrect parsing of diagonal directionals - no subsequent element', t => { + const service = (req, callback) => { + const response = [ + { + 'label': 'test', + 'value': 'test' + }, + { + 'label': 'road', + 'value': 'nw' + } + ]; + + callback(null, response); + }; + + const controller = libpostal(service, () => true); + + const req = { + clean: { + text: 'original query' + }, + errors: [] + }; + + controller(req, undefined, () => { + t.deepEquals(req, { + clean: { + text: 'original query', + parser: 'libpostal', + parsed_text: { + street: 'nw' + } + }, + errors: [] + }, 'req should not have been modified'); + + t.end(); + + }); + + }); + test('bug fix: recast label for "zoo" from borough/city_district to house', t => { const service = (req, callback) => { const response = [