Index: components/payments/core/payment_request_data_util_unittest.cc |
diff --git a/components/payments/core/payment_request_data_util_unittest.cc b/components/payments/core/payment_request_data_util_unittest.cc |
index 5ad7e10963776fb3ff6128ec493b5aa54dece491..30d8bd9f9903f108d1870503523094d4dfe946bb 100644 |
--- a/components/payments/core/payment_request_data_util_unittest.cc |
+++ b/components/payments/core/payment_request_data_util_unittest.cc |
@@ -49,6 +49,39 @@ TEST(PaymentRequestDataUtilTest, GetBasicCardResponseFromAutofillCreditCard) { |
card.set_billing_address_id(address.guid()); |
std::unique_ptr<base::DictionaryValue> response_value = |
payments::data_util::GetBasicCardResponseFromAutofillCreditCard( |
+ card, base::ASCIIToUTF16("123"), address, "en-US") |
+ .ToDictionaryValue(); |
+ std::string json_response; |
+ base::JSONWriter::Write(*response_value, &json_response); |
+ EXPECT_EQ( |
+ "{\"billingAddress\":" |
+ "{\"addressLine\":[\"666 Erebus St.\",\"Apt 8\"]," |
+ "\"city\":\"Elysium\"," |
+ "\"country\":\"US\"," |
+ "\"organization\":\"Underworld\"," |
+ "\"phone\":\"16502111111\"," |
+ "\"postalCode\":\"91111\"," |
+ "\"recipient\":\"John H. Doe\"," |
+ "\"region\":\"CA\"}," |
+ "\"cardNumber\":\"4111111111111111\"," |
+ "\"cardSecurityCode\":\"123\"," |
+ "\"cardholderName\":\"Test User\"," |
+ "\"expiryMonth\":\"11\"," |
+ "\"expiryYear\":\"2022\"}", |
+ json_response); |
+} |
+ |
+// Tests that the basic card response constructed from a credit card with |
+// associated billing address has the right structure once serialized. |
+// TODO(crbug.com/714655): Once the billing address is checked in the instrument |
+// on iOS, remove this. |
+TEST(PaymentRequestDataUtilTest, |
+ GetBasicCardResponseFromAutofillCreditCard_ios) { |
+ autofill::AutofillProfile address = autofill::test::GetFullProfile(); |
+ autofill::CreditCard card = autofill::test::GetCreditCard(); |
+ card.set_billing_address_id(address.guid()); |
+ std::unique_ptr<base::DictionaryValue> response_value = |
+ payments::data_util::GetBasicCardResponseFromAutofillCreditCard( |
card, base::ASCIIToUTF16("123"), |
std::vector<autofill::AutofillProfile*>{&address}, "en-US") |
.ToDictionaryValue(); |