-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
126 lines (108 loc) · 2.81 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import parseAddress from './index'
describe('Address Parser', () => {
test('It should handle PO Boxes', () => {
const inputs = [
'PO BOX 1234',
'PO Box 986',
'po box 37213',
'P.O. Box 5432',
'P O Box 8769',
]
const expectedOutputs = [
{ post_office_box_number: 'PO BOX 1234' },
{ post_office_box_number: 'PO BOX 986' },
{ post_office_box_number: 'PO BOX 37213' },
{ post_office_box_number: 'PO BOX 5432' },
{ post_office_box_number: 'PO BOX 8769' },
]
inputs.map(( input, index ) => {
const output = parseAddress(input)
expect(output).toEqual(expectedOutputs[index])
})
})
test('It should handle apartments', () => {
const inputs = [
'7209 J EAST WT PARK BLVD #119',
'1120 Tinley Place #102',
]
const expectedOutputs = [
{
street_address: '7209 J EAST WT PARK BLVD',
street_address2: '#119',
},
{
street_address: '1120 TINLEY PL',
street_address2: '#102'
},
]
inputs.map(( input, index ) => {
const output = parseAddress(input)
expect(output).toEqual(expectedOutputs[index])
})
})
test('It should handle unit / apartment / suite numbers', () => {
const inputs = [
'123 W Simon Ave Unit 2D',
'345 N Ace Drive 4A',
'11201 OAK LAKE DR 1E',
'703 YELLOW VALLEY ROAD STE 201',
'434 FAYETTEVILLE ST. SUITE 2020',
'506 FALLING ROCKS CT APT 3112',
]
const expectedOutputs = [
{
street_address: '123 W SIMON AVE',
street_address2: 'UNIT 2D',
},
{
street_address: '345 N ACE DR',
street_address2: '4A',
},
{
street_address: '11201 OAK LAKE DR',
street_address2: '1E',
},
{
street_address: '703 YELLOW VALLEY RD',
street_address2: 'STE 201',
},
{
street_address: '434 FAYETTEVILLE ST',
street_address2: 'SUITE 2020',
},
{
street_address: '506 FALLING ROCKS CT',
street_address2: 'APT 3112',
},
]
inputs.map(( input, index ) => {
const output = parseAddress(input)
expect(output).toEqual(expectedOutputs[index])
})
})
test('It should handle numbered highway addresses', () => {
const inputs = [
'104 NC HWY 305',
'567 Highway 204',
]
const expectedOutputs = [
{
street_address: '104 NC HWY 305',
street_address2: ''
},
{
street_address: '567 HWY 204',
street_address2: '',
}
]
inputs.map(( input, index ) => {
const output = parseAddress(input)
expect(output).toEqual(expectedOutputs[index])
})
})
test('It should handle directional suffixes', () => {
const inputs = [
'515 6TH ST NW',
]
})
})