Skip to content

Commit 461e626

Browse files
committed
use internal data for basic lookup tests
1 parent 8137334 commit 461e626

File tree

2 files changed

+32
-146
lines changed

2 files changed

+32
-146
lines changed

test/abbr_lookups.js

-78
This file was deleted.

test/basic_lookups.js

+32-68
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,41 @@
22

33
const test = require('tape');
44

5-
const LOOKUP_STRINGS = {
6-
'Alabama': 'AL',
7-
'Alaska': 'AK',
8-
'American Samoa': 'AS',
9-
'Arizona': 'AZ',
10-
'Arkansas': 'AR',
11-
'California': 'CA',
12-
'Colorado': 'CO',
13-
'Connecticut': 'CT',
14-
'Delaware': 'DE',
15-
'District of Columbia': 'DC',
16-
'Florida': 'FL',
17-
'Georgia': 'GA',
18-
'Guam': 'GU',
19-
'Hawaii': 'HI',
20-
'Idaho': 'ID',
21-
'Illinois': 'IL',
22-
'Indiana': 'IN',
23-
'Iowa': 'IA',
24-
'Kansas': 'KS',
25-
'Kentucky': 'KY',
26-
'Louisiana': 'LA',
27-
'Maine': 'ME',
28-
'Maryland': 'MD',
29-
'Massachusets': 'MA',
30-
'Michigan': 'MI',
31-
'Minnesota': 'MN',
32-
'Mississippi': 'MS',
33-
'Missouri': 'MO',
34-
'Montana': 'MT',
35-
'Nebraska': 'NE',
36-
'Nevada': 'NV',
37-
'New Hampshire': 'NH',
38-
'New Jersey': 'NJ',
39-
'New Mexico': 'NM',
40-
'New York': 'NY',
41-
'North Carolina': 'NC',
42-
'North Dakota': 'ND',
43-
'Northern Mariana Islands': 'MP',
44-
'Ohio': 'OH',
45-
'Oklahoma': 'OK',
46-
'Oregon': 'OR',
47-
'Pennsylvania': 'PA',
48-
'Puerto Rico': 'PR',
49-
'Rhode Island': 'RI',
50-
'South Carolina': 'SC',
51-
'South Dakota': 'SD',
52-
'Tennessee': 'TN',
53-
'Texas': 'TX',
54-
'Utah': 'UT',
55-
'Vermont': 'VT',
56-
'Virgin Islands': 'VI',
57-
'Virginia': 'VA',
58-
'Washington': 'WA',
59-
'West Virgina': 'WV',
60-
'Wisconsin': 'WI',
61-
'Wyoming': 'WY'
62-
};
63-
64-
test('lookups', t => {
5+
test('name lookups', t => {
656

667
const us = require('../us.js');
678

68-
Object.keys(LOOKUP_STRINGS).forEach(lookup_key => {
69-
const expected_result = LOOKUP_STRINGS[lookup_key];
70-
const result = us.lookup(lookup_key);
71-
t.equal(result && result.abbr, expected_result, `${ lookup_key } => ${ expected_result }`);
72-
if ( !result || result.abbr !== expected_result ) {
73-
console.log( `${ lookup_key } = metaphone: ${ us._metaphone( lookup_key ) }` );
9+
us.STATES.forEach( state => {
10+
const result = us.lookup( state.name );
11+
t.deepEqual( result, state, `${ state.name } => ${ state.name }`);
12+
if ( !result || result.abbr !== state.abbr ) {
13+
console.log( `${ state.name } = metaphone: ${ us._metaphone( state.name ) }` );
7414
}
75-
});
15+
} );
16+
17+
t.end();
18+
} );
19+
20+
test('abbreviation lookups', t => {
21+
22+
const us = require('../us.js');
23+
24+
us.STATES.forEach( state => {
25+
const result = us.lookup( state.abbr );
26+
t.deepEqual( result, state, `${ state.abbr } => ${ state.name }`);
27+
} );
28+
29+
t.end();
30+
} );
31+
32+
test('fips lookups', t => {
33+
34+
const us = require('../us.js');
35+
36+
us.STATES.forEach( state => {
37+
const result = us.lookup( state.fips );
38+
t.deepEqual( result, state, `${ state.fips } => ${ state.name }`);
39+
} );
7640

7741
t.end();
78-
});
42+
} );

0 commit comments

Comments
 (0)