From a31f1a8561f34b29b2a31597c97464bc42737e3a Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 29 Oct 2018 21:15:03 -0400 Subject: [PATCH] Add failing test case for one postcode deduping --- test/unit/middleware/dedupe.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/unit/middleware/dedupe.js b/test/unit/middleware/dedupe.js index 674a2b10..b1b6e9ef 100644 --- a/test/unit/middleware/dedupe.js +++ b/test/unit/middleware/dedupe.js @@ -1,6 +1,7 @@ var data = require('../fixture/dedupe_elasticsearch_results'); var nonAsciiData = require('../fixture/dedupe_elasticsearch_nonascii_results'); var customLayerData = require('../fixture/dedupe_elasticsearch_custom_layer_results'); +var onlyPostalcodeDiffers = require('../fixture/dedupe_only_postalcode_differs'); var dedupe = require('../../../middleware/dedupe')(); module.exports.tests = {}; @@ -75,6 +76,24 @@ module.exports.tests.dedupe = function(test, common) { t.end(); }); }); + + test('test records with no address except one has postalcode', function(t) { + var req = { + clean: { + size: 20 + } + }; + var res = { + data: onlyPostalcodeDiffers + }; + var expected = onlyPostalcodeDiffers[1]; // non-canonical record + + dedupe(req, res, function () { + t.equal(res.data.length, 1, 'only one result displayed'); + t.equal(res.data[0], expected, 'record with postalcode is preferred'); + t.end(); + }); + }); };