| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/payments/core/payment_request_data_util.h" | 5 #include "components/payments/core/payment_request_data_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 "\"recipient\":\"John H. Doe\"," | 65 "\"recipient\":\"John H. Doe\"," |
| 66 "\"region\":\"CA\"}," | 66 "\"region\":\"CA\"}," |
| 67 "\"cardNumber\":\"4111111111111111\"," | 67 "\"cardNumber\":\"4111111111111111\"," |
| 68 "\"cardSecurityCode\":\"123\"," | 68 "\"cardSecurityCode\":\"123\"," |
| 69 "\"cardholderName\":\"Test User\"," | 69 "\"cardholderName\":\"Test User\"," |
| 70 "\"expiryMonth\":\"11\"," | 70 "\"expiryMonth\":\"11\"," |
| 71 "\"expiryYear\":\"2022\"}", | 71 "\"expiryYear\":\"2022\"}", |
| 72 json_response); | 72 json_response); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Tests that the phone numbers are correctly formatted for the Payment |
| 76 // Response. |
| 77 TEST(PaymentRequestDataUtilTest, FormatPhoneForResponse) { |
| 78 EXPECT_EQ("+15151231234", payments::data_util::FormatPhoneForResponse( |
| 79 "(515) 123-1234", "US")); |
| 80 EXPECT_EQ("+15151231234", payments::data_util::FormatPhoneForResponse( |
| 81 "(1) 515-123-1234", "US")); |
| 82 EXPECT_EQ("+33142685300", |
| 83 payments::data_util::FormatPhoneForResponse("1 42 68 53 00", "FR")); |
| 84 } |
| 85 |
| 86 // Tests that the phone numbers are correctly formatted to display to the user. |
| 87 TEST(PaymentRequestDataUtilTest, FormatPhoneForDisplay) { |
| 88 EXPECT_EQ("+1 515-123-1234", |
| 89 payments::data_util::FormatPhoneForDisplay("5151231234", "US")); |
| 90 EXPECT_EQ("+33 1 42 68 53 00", |
| 91 payments::data_util::FormatPhoneForDisplay("142685300", "FR")); |
| 92 } |
| 93 |
| 75 } // namespace data_util | 94 } // namespace data_util |
| 76 } // namespace payments | 95 } // namespace payments |
| OLD | NEW |