From 261da83ef08b633add643749a8887a4b24a9eb44 Mon Sep 17 00:00:00 2001 From: missinglink Date: Tue, 1 Mar 2022 14:42:00 +0100 Subject: [PATCH] feat(dedupe): do not dedupe disparate unit numbers at same address --- helper/diffPlaces.js | 1 + test/unit/helper/diffPlaces.js | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/helper/diffPlaces.js b/helper/diffPlaces.js index 0094f212b..b12a3501f 100644 --- a/helper/diffPlaces.js +++ b/helper/diffPlaces.js @@ -157,6 +157,7 @@ function isAddressDifferent(item1, item2){ if( !isPojo1 || !isPojo2 ){ return false; } // else both have address info + if( isPropertyDifferent(address1, address2, 'unit') ){ return true; } if( isPropertyDifferent(address1, address2, 'number') ){ return true; } if( isPropertyDifferent(address1, address2, 'street') ){ return true; } diff --git a/test/unit/helper/diffPlaces.js b/test/unit/helper/diffPlaces.js index 2304ad469..dc94f8674 100644 --- a/test/unit/helper/diffPlaces.js +++ b/test/unit/helper/diffPlaces.js @@ -438,6 +438,45 @@ module.exports.tests.dedupe = function(test, common) { t.end(); }); + test('same address, different unit number', function (t) { + var item1 = { + 'address_parts': { + 'unit': '1', + 'number': '10', + 'street': 'Main Street' + } + }; + var item2 = { + 'address_parts': { + 'unit': '2', + 'number': '10', + 'street': 'Main Street' + } + }; + + t.true(isDifferent(item1, item2), 'should be different'); + t.end(); + }); + + test('same address, different one missing unit number', function (t) { + var item1 = { + 'address_parts': { + 'number': '10', + 'street': 'Main Street' + } + }; + var item2 = { + 'address_parts': { + 'unit': '2', + 'number': '10', + 'street': 'Main Street' + } + }; + + t.true(isDifferent(item1, item2), 'should be different'); + t.end(); + }); + test('completely empty objects', function(t) { var item1 = {}; var item2 = {};