Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Adding address unit attribute to parsed properties #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/addressItParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function parse(query) {
addressWithAddressParts);

var address_parts = [ 'name',
'unit',
'number',
'street',
'city',
Expand Down
1 change: 1 addition & 0 deletions src/libpostalParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var field_mapping = {
island: 'island',
category: 'category',
house: 'query',
unit: 'unit',
house_number: 'number',
road: 'street',
suburb: 'neighbourhood',
Expand Down
11 changes: 11 additions & 0 deletions test/addressItParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ tape('tests', function(test) {
t.equal(address.state , 'NY', 'parsed state');
t.end();
});
test.test('valid address, unt', function(t) {
var query_string = 'Shop 8, 431 St Kilda Rd Melbourne';
var address = parser.parse(query_string);

t.equal(typeof address, 'object', 'valid object for the address');
t.equal(address.unit , '8', 'parsed unit');
t.equal(address.number, '431', 'parsed house number');
t.equal(address.street, 'St Kilda Rd', 'parsed street');
t.deepEqual(address.regions, ['Melbourne'], 'parsed city');
t.end();
});
test.test('valid address, house number', function(t) {
var query_string = '123 main st new york ny';
var address = parser.parse(query_string);
Expand Down
5 changes: 5 additions & 0 deletions test/libpostalParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ tape('tests', function(test) {
component: 'house',
value: 'house value'
},
{
component: 'unit',
value: 'unit value'
},
{
component: 'house_number',
value: 'house_number value'
Expand Down Expand Up @@ -87,6 +91,7 @@ tape('tests', function(test) {
island: 'island value',
category: 'category value',
query: 'house value',
unit: 'unit value',
number: 'house_number value',
street: 'road value',
neighbourhood: 'suburb value',
Expand Down