-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f83f041
commit 987ba96
Showing
37 changed files
with
1,676 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
src/__tests__/generate/__snapshots__/write-addresses-json.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`write addresses json: pretty = false 1`] = `"[{"postalCode":"0600000","regionId":1,"region":"北海道","locality":"札幌市中央区","address1":"","address2":"","regionKana":"ホッカイドウ","localityKana":"サッポロシチュウオウク","address1Kana":"","address2Kana":""}]"`; | ||
|
||
exports[`write addresses json: pretty = false 2`] = `"[{"postalCode":"0360223","regionId":2,"region":"青森県","locality":"平川市","address1":"西野曽江川崎","address2":"","regionKana":"アオモリケン","localityKana":"ヒラカワシ","address1Kana":"ニシノゾエカワサキ","address2Kana":""},{"postalCode":"0360223","regionId":2,"region":"青森県","locality":"平川市","address1":"西野曽江橋元","address2":"","regionKana":"アオモリケン","localityKana":"ヒラカワシ","address1Kana":"ニシノゾエハシモト","address2Kana":""},{"postalCode":"0360223","regionId":2,"region":"青森県","locality":"平川市","address1":"西野曽江広田","address2":"","regionKana":"アオモリケン","localityKana":"ヒラカワシ","address1Kana":"ニシノゾエヒロタ","address2Kana":""}]"`; | ||
|
||
exports[`write addresses json: pretty = true 1`] = ` | ||
"[ | ||
{ | ||
"postalCode": "0600000", | ||
"regionId": 1, | ||
"region": "北海道", | ||
"locality": "札幌市中央区", | ||
"address1": "", | ||
"address2": "", | ||
"regionKana": "ホッカイドウ", | ||
"localityKana": "サッポロシチュウオウク", | ||
"address1Kana": "", | ||
"address2Kana": "" | ||
} | ||
]" | ||
`; | ||
|
||
exports[`write addresses json: pretty = true 2`] = ` | ||
"[ | ||
{ | ||
"postalCode": "0360223", | ||
"regionId": 2, | ||
"region": "青森県", | ||
"locality": "平川市", | ||
"address1": "西野曽江川崎", | ||
"address2": "", | ||
"regionKana": "アオモリケン", | ||
"localityKana": "ヒラカワシ", | ||
"address1Kana": "ニシノゾエカワサキ", | ||
"address2Kana": "" | ||
}, | ||
{ | ||
"postalCode": "0360223", | ||
"regionId": 2, | ||
"region": "青森県", | ||
"locality": "平川市", | ||
"address1": "西野曽江橋元", | ||
"address2": "", | ||
"regionKana": "アオモリケン", | ||
"localityKana": "ヒラカワシ", | ||
"address1Kana": "ニシノゾエハシモト", | ||
"address2Kana": "" | ||
}, | ||
{ | ||
"postalCode": "0360223", | ||
"regionId": 2, | ||
"region": "青森県", | ||
"locality": "平川市", | ||
"address1": "西野曽江広田", | ||
"address2": "", | ||
"regionKana": "アオモリケン", | ||
"localityKana": "ヒラカワシ", | ||
"address1Kana": "ニシノゾエヒロタ", | ||
"address2Kana": "" | ||
} | ||
]" | ||
`; |
135 changes: 135 additions & 0 deletions
135
src/__tests__/generate/create-postal-code-addresses-map.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { createPostalCodeAddressesMap } from '@/lib/generate/create-postal-code-addresses-map'; | ||
import { Address } from '@/lib/types/address'; | ||
import { KenAllRecord } from '@/lib/types/ken-all-record'; | ||
import { expect, test } from '@jest/globals'; | ||
|
||
test('returns map', async () => { | ||
const map = await createPostalCodeAddressesMap(mockRecordGenerator()); | ||
|
||
expect([...map.keys()]).toEqual(['0600000', '0360223']); | ||
|
||
expect(map.get('0600000')).toEqual([ | ||
{ | ||
postalCode: '0600000', | ||
regionId: 1, | ||
region: '北海道', | ||
locality: '札幌市中央区', | ||
address1: '', | ||
address2: '', | ||
regionKana: 'ホッカイドウ', | ||
localityKana: 'サッポロシチュウオウク', | ||
address1Kana: '', | ||
address2Kana: '', | ||
}, | ||
] as Address[]); | ||
|
||
expect(map.get('0360223')).toEqual([ | ||
{ | ||
postalCode: '0360223', | ||
regionId: 2, | ||
region: '青森県', | ||
locality: '平川市', | ||
address1: '西野曽江川崎', | ||
address2: '', | ||
regionKana: 'アオモリケン', | ||
localityKana: 'ヒラカワシ', | ||
address1Kana: 'ニシノゾエカワサキ', | ||
address2Kana: '', | ||
}, | ||
{ | ||
postalCode: '0360223', | ||
regionId: 2, | ||
region: '青森県', | ||
locality: '平川市', | ||
address1: '西野曽江橋元', | ||
address2: '', | ||
regionKana: 'アオモリケン', | ||
localityKana: 'ヒラカワシ', | ||
address1Kana: 'ニシノゾエハシモト', | ||
address2Kana: '', | ||
}, | ||
{ | ||
postalCode: '0360223', | ||
regionId: 2, | ||
region: '青森県', | ||
locality: '平川市', | ||
address1: '西野曽江広田', | ||
address2: '', | ||
regionKana: 'アオモリケン', | ||
localityKana: 'ヒラカワシ', | ||
address1Kana: 'ニシノゾエヒロタ', | ||
address2Kana: '', | ||
}, | ||
] as Address[]); | ||
}); | ||
|
||
async function* mockRecordGenerator(): AsyncGenerator<KenAllRecord> { | ||
yield [ | ||
'01101', | ||
'060 ', | ||
'0600000', | ||
'ホッカイドウ', | ||
'サッポロシチュウオウク', | ||
'イカニケイサイガナイバアイ', | ||
'北海道', | ||
'札幌市中央区', | ||
'以下に掲載がない場合', | ||
'0', | ||
'0', | ||
'0', | ||
'0', | ||
'0', | ||
'0', | ||
]; | ||
yield [ | ||
'02210', | ||
'03602', | ||
'0360223', | ||
'アオモリケン', | ||
'ヒラカワシ', | ||
'ニシノゾエカワサキ', | ||
'青森県', | ||
'平川市', | ||
'西野曽江川崎', | ||
'0', | ||
'1', | ||
'0', | ||
'1', | ||
'0', | ||
'0', | ||
]; | ||
yield [ | ||
'02210', | ||
'03602', | ||
'0360223', | ||
'アオモリケン', | ||
'ヒラカワシ', | ||
'ニシノゾエハシモト', | ||
'青森県', | ||
'平川市', | ||
'西野曽江橋元', | ||
'0', | ||
'1', | ||
'0', | ||
'1', | ||
'0', | ||
'0', | ||
]; | ||
yield [ | ||
'02210', | ||
'03602', | ||
'0360223', | ||
'アオモリケン', | ||
'ヒラカワシ', | ||
'ニシノゾエヒロタ', | ||
'青森県', | ||
'平川市', | ||
'西野曽江広田', | ||
'0', | ||
'1', | ||
'0', | ||
'1', | ||
'0', | ||
'0', | ||
]; | ||
} |
Oops, something went wrong.