Skip to content

Commit

Permalink
[INTER-3577] Fix undefined shipping address issue
Browse files Browse the repository at this point in the history
  • Loading branch information
BoldCole committed May 17, 2024
1 parent 9918b1d commit a8813a5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/fastlane/fastlane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class Fastlane {
profileData: {
card: resp.profileData.card,
name: resp.profileData.name,
shippingAddress: this.transformPaypalAddress(paypalAddress),
shippingAddress: paypalAddress === undefined ? undefined : this.transformPaypalAddress(paypalAddress),
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/fastlane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface IFastlaneAuthenticatedCustomerResult {
firstName: string;
lastName: string;
};
shippingAddress: IFastlaneAddress;
shippingAddress: IFastlaneAddress | undefined;
card: IFastlanePaymentToken;
}
}
Expand Down
18 changes: 17 additions & 1 deletion tests/fastlane/fastlane.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Fastlane from 'src/fastlane/fastlane';
import { IFastlaneAuthenticatedCustomerResult } from 'src';

describe('testing Fastlane class', () => {
const fastlaneInstanceMock = {
Expand Down Expand Up @@ -91,6 +92,7 @@ describe('testing Fastlane class', () => {

test.each([
{
name: 'ppcp',
type: 'ppcp',
respProfileData: {
card: {},
Expand Down Expand Up @@ -133,6 +135,20 @@ describe('testing Fastlane class', () => {
}),
} as const,
{
name: 'ppcp - no shipping address',
type: 'ppcp',
respProfileData: {
card: {},
name: {
firstName: 'firstName',
lastName: 'firstName',
},
shippingAddress: undefined,
},
expected: (): IFastlaneAuthenticatedCustomerResult['profileData']['shippingAddress'] => undefined,
} as const,
{
name: 'braintree',
type: 'braintree',
respProfileData: {
card: {},
Expand All @@ -157,7 +173,7 @@ describe('testing Fastlane class', () => {
return this.respProfileData.shippingAddress;
},
} as const,
])('$type triggerAuthenticationFlow', async (input) => {
])('$name triggerAuthenticationFlow', async (input) => {
// Arranging
fastlaneInstanceMock.identity.triggerAuthenticationFlow.mockResolvedValue({
authenticationState: 'succeeded',
Expand Down

0 comments on commit a8813a5

Please sign in to comment.