From fc73ce7f64eb0c7e5315eeb5691581058b275c89 Mon Sep 17 00:00:00 2001 From: Andrew Terranova Date: Mon, 7 Dec 2020 13:07:36 -0600 Subject: [PATCH] Adds middle name to AddressCard display --- .../__snapshots__/addressCard.spec.js.snap | 98 +++++++++++++++++++ .../__tests__/addressCard.spec.js | 16 +++ .../components/AddressBookPage/addressCard.js | 5 +- 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/packages/venia-ui/lib/components/AddressBookPage/__tests__/__snapshots__/addressCard.spec.js.snap b/packages/venia-ui/lib/components/AddressBookPage/__tests__/__snapshots__/addressCard.spec.js.snap index d38bf6a0f5..b65459e79f 100644 --- a/packages/venia-ui/lib/components/AddressBookPage/__tests__/__snapshots__/addressCard.spec.js.snap +++ b/packages/venia-ui/lib/components/AddressBookPage/__tests__/__snapshots__/addressCard.spec.js.snap @@ -241,3 +241,101 @@ exports[`renders a non-default address 1`] = ` `; + +exports[`renders an address with a middle name 1`] = ` +
+
+ + + + + Philip MIDDLE Fry + + + 111 57th Street + + + Suite 1000 + + + New New York, New York 10019 + + + United States + + + + +
+
+ +
+
+`; diff --git a/packages/venia-ui/lib/components/AddressBookPage/__tests__/addressCard.spec.js b/packages/venia-ui/lib/components/AddressBookPage/__tests__/addressCard.spec.js index 5e4b0b670e..ad553b0021 100644 --- a/packages/venia-ui/lib/components/AddressBookPage/__tests__/addressCard.spec.js +++ b/packages/venia-ui/lib/components/AddressBookPage/__tests__/addressCard.spec.js @@ -31,3 +31,19 @@ test('renders a non-default address', () => { expect(tree.toJSON()).toMatchSnapshot(); }); + +test('renders an address with a middle name', () => { + // Arrange. + const myAddress = { + ...mockAddress, + middlename: 'MIDDLE' + }; + + // Act. + const tree = createTestInstance( + + ); + + // Assert. + expect(tree.toJSON()).toMatchSnapshot(); +}); diff --git a/packages/venia-ui/lib/components/AddressBookPage/addressCard.js b/packages/venia-ui/lib/components/AddressBookPage/addressCard.js index 4e9059dbb0..9c02842473 100644 --- a/packages/venia-ui/lib/components/AddressBookPage/addressCard.js +++ b/packages/venia-ui/lib/components/AddressBookPage/addressCard.js @@ -16,6 +16,7 @@ const AddressCard = props => { country_code, default_shipping, firstname, + middlename = '', lastname, postcode, region: { region }, @@ -42,7 +43,9 @@ const AddressCard = props => { ) : null; - const nameString = `${firstname} ${lastname}`; + const nameString = [firstname, middlename, lastname] + .filter(name => !!name) + .join(' '); const additionalAddressString = `${city}, ${region} ${postcode}`; const deleteButtonElement = !default_shipping ? (