Browse Source

Update addressit module to not strip 0s from zipcodes

pull/368/head
Diana Shkolnikov 9 years ago
parent
commit
500835a4c1
  1. 2
      package.json
  2. 2
      test/ciao/search/address_parsing.coffee
  3. 4
      test/unit/fixture/search_full_address.js
  4. 2
      test/unit/fixture/search_regions_address.js
  5. 18
      test/unit/helper/text_parser.js

2
package.json

@ -33,7 +33,7 @@
"elasticsearch": ">=1.2.1"
},
"dependencies": {
"addressit": "1.3.0",
"addressit": "git://github.com/dianashk/addressit.git@9da3f04128c22b28710a993a4cedd0ad4f5aa4a3",
"async": "^0.9.0",
"check-types": "^3.3.1",
"cluster2": "git://github.com/missinglink/cluster2.git#node_zero_twelve",

2
test/ciao/search/address_parsing.coffee

@ -34,7 +34,7 @@ json.geocoding.query['size'].should.eql 10
#? address parsing
json.geocoding.query.parsed_text['name'].should.eql '30 w 26th st'
json.geocoding.query.parsed_text['number'].should.eql 30
json.geocoding.query.parsed_text['number'].should.eql '30'
json.geocoding.query.parsed_text['street'].should.eql 'w 26th st'
json.geocoding.query.parsed_text['state'].should.eql 'NY'
json.geocoding.query.parsed_text['regions'].should.eql []

4
test/unit/fixture/search_full_address.js

@ -88,7 +88,7 @@ module.exports = {
},{
'match': {
'address.number': {
'query': 123,
'query': '123',
'boost': vs.var('address:housenumber:boost').get(),
'analyzer': vs.var('address:housenumber:analyzer').get()
}
@ -104,7 +104,7 @@ module.exports = {
}, {
'match': {
'address.zip': {
'query': 10010,
'query': '10010',
'boost': vs.var('address:postcode:boost').get(),
'analyzer': vs.var('address:postcode:analyzer').get()
}

2
test/unit/fixture/search_regions_address.js

@ -87,7 +87,7 @@ module.exports = {
},{
'match': {
'address.number': {
'query': 1,
'query': '1',
'boost': vs.var('address:housenumber:boost').get(),
'analyzer': vs.var('address:housenumber:analyzer').get()
}

18
test/unit/helper/text_parser.js

@ -85,7 +85,7 @@ module.exports.tests.parse_address = function(test, common) {
var address = parser.get_parsed_address(query_string);
t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.number, 123, 'parsed house number');
t.equal(address.number, '123', 'parsed house number');
t.equal(address.street, 'main st', 'parsed street');
t.deepEqual(address.regions, ['new york'], 'parsed city');
t.equal(address.state , 'NY', 'parsed state');
@ -96,11 +96,23 @@ module.exports.tests.parse_address = function(test, common) {
var address = parser.get_parsed_address(query_string);
t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.number, 123, 'parsed house number');
t.equal(address.number, '123', 'parsed house number');
t.equal(address.street, 'main st', 'parsed street');
t.deepEqual(address.regions, ['new york'], 'parsed city');
t.equal(address.state , 'NY', 'parsed state');
t.equal(address.postalcode, 10010, 'parsed zip');
t.equal(address.postalcode, '10010', 'parsed zip is a string');
t.end();
});
test('valid address with leading 0s in zipcode', function(t) {
var query_string = '339 W Main St, Cheshire, 06410';
var address = parser.get_parsed_address(query_string);
console.log(address);
t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.street, 'W Main St', 'parsed street');
t.deepEqual(address.regions, ['Cheshire'], 'parsed city');
t.equal(address.postalcode, '06410', 'parsed zip');
t.end();
});
};

Loading…
Cancel
Save