Browse Source

Add failing test case for one postcode deduping

dedupe-failing-test-case
Julian Simioni 6 years ago
parent
commit
6c04036d75
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 27
      test/unit/fixture/dedupe_only_postalcode_differs.js
  2. 19
      test/unit/middleware/dedupe.js

27
test/unit/fixture/dedupe_only_postalcode_differs.js

@ -0,0 +1,27 @@
module.exports = [
{
'_id': '101914069',
'layer': 'venue',
'source': 'openstreetmap',
'name': {
'default': 'A place'
},
'parent': {
'country_a': ['USA']
}
},
{
'_id': '323',
'layer': 'venue',
'source': 'openstreetmap',
'name': {
'default': 'A place'
},
'address_parts': {
'zip': '97005'
},
'parent': {
'country_a': ['USA']
}
}
];

19
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();
});
});
};

Loading…
Cancel
Save