-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for amazon pay express and apple pay express (#1082)
- Loading branch information
Showing
4 changed files
with
147 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ const { | |
handleError, | ||
handleApplePayResponse, | ||
callPaymentFromComponent, | ||
formatCustomerObject, | ||
} = require('../../applePayExpress'); | ||
|
||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
|
||
|
@@ -97,4 +99,69 @@ describe('Apple Pay Express', () => { | |
JSON.stringify(response.fullResponse), | ||
); | ||
}); | ||
|
||
it('Should format customer and billing data correctly', () => { | ||
const customerData = { | ||
addressLines: ['123 Main St', 'Apt 2'], | ||
locality: 'City', | ||
country: 'United States', | ||
countryCode: 'US', | ||
givenName: 'John', | ||
familyName: 'Doe', | ||
emailAddress: '[email protected]', | ||
postalCode: '12345', | ||
administrativeArea: 'State', | ||
phoneNumber: '+1234567890', | ||
}; | ||
const billingData = { | ||
addressLines: ['456 Oak St'], | ||
locality: 'Town', | ||
country: 'United States', | ||
countryCode: 'US', | ||
givenName: 'Jane', | ||
familyName: 'Doe', | ||
postalCode: '54321', | ||
administrativeArea: 'Province', | ||
}; | ||
const formattedData = formatCustomerObject(customerData, billingData); | ||
expect(formattedData).toEqual({ | ||
addressBook: { | ||
addresses: {}, | ||
preferredAddress: { | ||
address1: '123 Main St', | ||
address2: 'Apt 2', | ||
city: 'City', | ||
countryCode: { | ||
displayValue: 'United States', | ||
value: 'US', | ||
}, | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
ID: '[email protected]', | ||
postalCode: '12345', | ||
stateCode: 'State', | ||
}, | ||
}, | ||
billingAddressDetails: { | ||
address1: '456 Oak St', | ||
address2: null, | ||
city: 'Town', | ||
countryCode: { | ||
displayValue: 'United States', | ||
value: 'US', | ||
}, | ||
firstName: 'Jane', | ||
lastName: 'Doe', | ||
postalCode: '54321', | ||
stateCode: 'Province', | ||
}, | ||
customer: {}, | ||
profile: { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
email: '[email protected]', | ||
phone: '+1234567890', | ||
}, | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,4 +307,5 @@ module.exports = { | |
handleError, | ||
handleApplePayResponse, | ||
callPaymentFromComponent, | ||
formatCustomerObject, | ||
}; |