Skip to content

Commit

Permalink
CXINT-2613 (#18045)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjana-bl authored Oct 31, 2023
1 parent 945375c commit 861f850
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
34 changes: 34 additions & 0 deletions feature-libs/order/root/utils/order-card-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ describe('Order Card utils', () => {
postalCode: 'zip',
country: mockCountry,
};
const mockAddress2: Address = {
line1: 'Toyosaki 2 create on cart',
line2: 'line2',
town: 'town',
region: { isocode: 'JP-27' },
postalCode: 'zip',
country: mockCountry,
};
const mockAddress3: Address = {
titleCode: 'mr',
firstName: 'John',
line1: 'Toyosaki 2 create on cart',
line2: 'line2',
town: 'town',
region: { isocode: 'JP-27' },
postalCode: 'zip',
country: mockCountry,
};

it('should return delivery address card', () => {
const card = deliveryAddressCard(
Expand All @@ -42,6 +60,22 @@ describe('Order Card utils', () => {
'zip',
undefined,
]);
const card2 = deliveryAddressCard(
'title',
'phone',
'mobile',
mockAddress2,
'Canada'
);
expect(card2.textBold).toEqual(undefined);
const card3 = deliveryAddressCard(
'title',
'phone',
'mobile',
mockAddress3,
'Canada'
);
expect(card3.textBold).toEqual('John');
});
});

Expand Down
10 changes: 9 additions & 1 deletion feature-libs/order/root/utils/order-card-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ export function deliveryAddressCard(
}

const numbers = getAddressNumbers(deliveryAddress, textPhone, textMobile);
let fullName;
if (deliveryAddress.firstName && deliveryAddress.lastName) {
fullName = deliveryAddress.firstName + ' ' + deliveryAddress.lastName;
} else if (deliveryAddress.firstName) {
fullName = deliveryAddress.firstName;
} else if (deliveryAddress.lastName) {
fullName = deliveryAddress.lastName;
}

return {
title: textTitle,
textBold: deliveryAddress.firstName + ' ' + deliveryAddress.lastName,
textBold: fullName,
text: [
deliveryAddress.line1,
deliveryAddress.line2,
Expand Down

0 comments on commit 861f850

Please sign in to comment.