Skip to content

Commit

Permalink
address parse update w/ test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepage committed Apr 28, 2024
1 parent d39fe71 commit e9e723a
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/address/normalize/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/address-normalize",
"description": "A utility that normalizes an address string for ease of parsing",
"version": "2.4.4",
"version": "2.4.5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
4 changes: 4 additions & 0 deletions packages/address/normalize/src/lib/addressNormalize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ describe('addressNormalize', () => {
const fn = () => addressNormalize(longAddress);
expect(fn).toThrow('Address is too long');
});

it('should return an empty string when an empty string provided', () => {
expect(addressNormalize('')).toEqual('');
});
});
2 changes: 1 addition & 1 deletion packages/address/parse/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/address-parse",
"description": "An address parser for American and Canadian addresses that breaks down the provided address into its component parts",
"version": "0.1.5",
"version": "0.1.6",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
34 changes: 34 additions & 0 deletions packages/address/parse/src/lib/addressParse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,38 @@ describe('addressParse', () => {
stateAbbr: 'NY',
});
});

it('should parse an address with an apt, city, state & country', () => {
const addy = '123 Maple Street Rochester, New York 10001-1234';
expect(
addressParse(addy, {
city: 'Rochester',
state: 'New York',
country: 'USA',
zip: '10001',
zipExt: '1234',
})
).toEqual({
source: addy,
normalized: '123 MAPLE STREET ROCHESTER NEW YORK 10001-1234',
street: '123 MAPLE ST ROCHESTER',
city: 'ROCHESTER',
stateAbbr: 'NY',
zip: '10001',
zipExt: '1234',
countryIso2: 'US',
});
});

// TODO: fix this so the building is correctly identified
it('should parse an highway contract address', () => {
const addy = '10135 starr st sw';
expect(addressParse(addy)).toEqual({
source: addy,
normalized: '10135 STARR ST SW',

street: 'STARR ST SW',
zip: '10135',
});
});
});
1 change: 0 additions & 1 deletion packages/address/parse/src/lib/addressParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ export const addressParse = (
// edge case: stash is a building if it is numeric & there is no building
if (stash.length && !address.building && stash[0].isNumeric) {
const item = stash.pop();
console.log('item', item);
address.building = item.term;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/address/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/address",
"description": "A collection of address utilities and parsers",
"version": "2.4.6",
"version": "2.4.7",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/app",
"description": "A modern library/monorepo of high-quality, zero-dependency, fully typed, fully tested, tree-shakeable utilities, parsers, data structure factories, converters and other capabilities ",
"version": "2.8.10",
"version": "2.8.11",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/barrel/parsers/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zerodep/parsers",
"description": "A collection of all parsers within the @zerodep ecosystem",
"version": "2.4.6",
"version": "2.4.7",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit e9e723a

Please sign in to comment.