Skip to content

Commit

Permalink
adjust for Korea, allow propagation of province to state
Browse files Browse the repository at this point in the history
  • Loading branch information
tn819 committed Oct 8, 2024
1 parent 9522d72 commit 246d0ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lib/__tests__/postal-address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,15 @@ describe('Propagation', () => {
expect(myAddress.toObject().lastName).toBe('Doe')
expect(myAddress.toObject().secondLastName).toBe('Smith')
})

it('Propagation of changes to related properties overwrites with latest invoked even if both present', () => {
const myAddress = new PostalAddress()

myAddress.setCity('City')
myAddress.setSi('Si')
expect(myAddress.toObject().si).toBe('Si')
expect(myAddress.toObject().city).toBe('Si')

myAddress.setPropagation(false)
})
})
6 changes: 3 additions & 3 deletions lib/address-formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ const addressFormats: AddressFormats = {
KR: {
default: {
array: [
['country'],
['do', 'si', 'dong', 'gu', 'addressNum'],
['companyName'],
['lastName', 'firstName', 'honorific'],
['companyName'],
['do', 'si', 'dong', 'gu', 'addressNum'],
['postalCode', 'country'],
],
},
},
Expand Down
5 changes: 5 additions & 0 deletions lib/postal-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class PostalAddress implements PostalAddressInterface {

if (this.propagateToRelatedProperties) {
this.setProperty('do', newValue)
this.setProperty('state', newValue)
}
return this
}
Expand Down Expand Up @@ -321,6 +322,10 @@ class PostalAddress implements PostalAddressInterface {

public setState(newValue: string): this {
this.setProperty('state', newValue)

if (this.propagateToRelatedProperties) {
this.setProperty('province', newValue)
}
return this
}

Expand Down

0 comments on commit 246d0ed

Please sign in to comment.