Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INTER-3577] Fix undefined shipping address issue #26

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fastlane/fastlane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: IFastlaneInstance = {} as Fastlane;
type OmittedIFastlaneInstance = Omit<IFastlaneInstance, 'gatewayPublicId' | 'type'>;
type IFastlaneAddress = Awaited<ReturnType<IFastlaneInstance['identity']['triggerAuthenticationFlow']>>['profileData']['shippingAddress'];

Check warning on line 7 in src/fastlane/fastlane.ts

View workflow job for this annotation

GitHub Actions / Build

'IFastlaneAddress' is defined but never used

interface IPayPalAddress {
companyName?: string;
Expand Down Expand Up @@ -82,7 +82,7 @@
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
Loading