Browse Source

Merge pull request #383 from pelias/master

Merge master into staging
pull/384/head
Diana Shkolnikov 9 years ago
parent
commit
3748c5eca0
  1. 3
      middleware/confidenceScore.js
  2. 33
      test/unit/middleware/confidenceScore.js

3
middleware/confidenceScore.js

@ -100,7 +100,8 @@ function checkForDealBreakers(req, hit) {
return true; return true;
} }
if (check.assigned(req.clean.parsed_text.postalcode) && req.clean.parsed_text.postalcode !== hit.address.zip) { if (check.assigned(req.clean.parsed_text.postalcode) && check.assigned(hit.address) &&
req.clean.parsed_text.postalcode !== hit.address.zip) {
logger.debug('[confidence][deal-breaker]: postalcode !== zip (' + req.clean.parsed_text.postalcode + ' !== ' + hit.address.zip + ')'); logger.debug('[confidence][deal-breaker]: postalcode !== zip (' + req.clean.parsed_text.postalcode + ' !== ' + hit.address.zip + ')');
return true; return true;
} }

33
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) { test('res.results without parsed_text should not throw exception', function(t) {
var req = { var req = {

Loading…
Cancel
Save