From 5a84afa539c9ea77d3cf713f3d63e12763d475ca Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 7 Dec 2015 17:13:44 -0500 Subject: [PATCH] Add test of parsing hit with no address object In #369 I said I wouldn't bother testing for the case of the address object on hit being absent, but it turns out that does sometimes happen. --- test/unit/middleware/confidenceScore.js | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/unit/middleware/confidenceScore.js b/test/unit/middleware/confidenceScore.js index c32a37d4..69821293 100644 --- a/test/unit/middleware/confidenceScore.js +++ b/test/unit/middleware/confidenceScore.js @@ -41,6 +41,39 @@ module.exports.tests.confidenceScore = function(test, common) { }); + test('hit without address should not error', function(t) { + var req = { + clean: { + text: 'test name3', + parsed_text: { + postalcode: 12345 + } + } + }; + var res = { + data: [{ + name: { + default: 'foo' + } + }], + meta: { + scores: [10] + } + }; + + try { + confidenceScore(req, res, function() {}); + t.pass('no exception'); + } + catch (e) { + t.fail('an exception should not have been thrown with no address'); + console.log(e.stack); + } + finally { + t.end(); + } + }); + test('res.results without parsed_text should not throw exception', function(t) { var req = {