Browse Source

bumped addressit version, updated corresponding tests

pull/625/head
Stephen Hess 8 years ago
parent
commit
cad2c5f5ad
  1. 2
      package.json
  2. 68
      test/unit/sanitiser/_text_addressit.js

2
package.json

@ -35,7 +35,7 @@
"node": ">=0.10.26"
},
"dependencies": {
"addressit": "git://github.com/dianashk/addressit.git#temp",
"addressit": "1.4.0",
"async": "^2.0.0",
"check-types": "^7.0.0",
"elasticsearch": "^11.0.0",

68
test/unit/sanitiser/_text_addressit.js

@ -19,13 +19,67 @@ module.exports.tests.text_parser = function(test, common) {
t.end();
});
var queries = [
{ name: 'soho', admin_parts: 'new york' },
var usQueries = [
{ name: 'soho', admin_parts: 'new york', state: 'NY' },
{ name: '123 main', admin_parts: 'new york', state: 'NY' }
];
usQueries.forEach(function (query) {
test('naive parsing ' + query, function(t) {
var raw = {
text: query.name + ', ' + query.admin_parts
};
var clean = {};
var expected_clean = {
text: query.name + ', ' + query.admin_parts,
parsed_text: {
name: query.name,
regions: [ query.name ],
admin_parts: query.admin_parts,
state: query.state
}
};
var messages = sanitiser(raw, clean);
t.deepEqual(messages, { errors: [], warnings: [] } );
t.deepEqual(clean, expected_clean);
t.end();
});
test('naive parsing ' + query + ' without spaces', function(t) {
var raw = {
text: query.name + ',' + query.admin_parts
};
var clean = {};
var expected_clean = {
text: query.name + ',' + query.admin_parts,
parsed_text: {
name: query.name,
regions: [ query.name ],
admin_parts: query.admin_parts,
state: query.state
}
};
var messages = sanitiser(raw, clean);
t.deepEqual(messages, { errors: [], warnings: [] } );
t.deepEqual(clean, expected_clean);
t.end();
});
});
var nonUSQueries = [
{ name: 'chelsea', admin_parts: 'london' },
{ name: '123 main', admin_parts: 'new york' }
];
queries.forEach(function (query) {
nonUSQueries.forEach(function (query) {
test('naive parsing ' + query, function(t) {
var raw = {
text: query.name + ', ' + query.admin_parts
@ -158,7 +212,11 @@ module.exports.tests.text_parser = function(test, common) {
clean.parsed_text = 'this should be removed';
var expected_clean = {
text: 'main particle new york'
text: 'main particle new york',
parsed_text: {
regions: [ 'main particle' ],
state: 'NY'
}
};
var messages = sanitiser(raw, clean);

Loading…
Cancel
Save