Skip to content

Commit

Permalink
ppcp wallet pay shipping issue (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: shagufa-ali <80478231+shagufa-ali@users.noreply.github.com>
  • Loading branch information
Shagufa92 and shagufa-ali authored Nov 29, 2023
1 parent 665f4bc commit cebc545
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/paypal/ppcp_buttons/ppcpOnShippingChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
IWalletPayOnShippingRequest,
walletPayOnShipping
} from '@boldcommerce/checkout-frontend-library';
import {API_RETRY, displayError,} from 'src';
import {API_RETRY} from 'src';


export async function ppcpOnShippingChange(data: OnShippingChangeData, actions: OnShippingChangeActions): Promise<void> {
Expand All @@ -20,7 +20,6 @@ export async function ppcpOnShippingChange(data: OnShippingChangeData, actions:

const res = await walletPayOnShipping(body, API_RETRY);
if (!res.success) {
displayError('There was an unknown error while getting the shipping details.', 'payment_gateway', 'unknown_error');
return actions.reject();
}

Expand Down
8 changes: 2 additions & 6 deletions tests/paypal/ppcp_buttons/ppcpOnShippingChange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import {
walletPayOnShipping
} from '@boldcommerce/checkout-frontend-library';
import {applicationStateMock} from '@boldcommerce/checkout-frontend-library/lib/variables/mocks';
import {displayError} from 'src';
import {ppcpOnShippingChange} from 'src/paypal/ppcp_buttons/ppcpOnShippingChange';
import {OnShippingChangeActions, OnShippingChangeData} from '@paypal/paypal-js/types/components/buttons';

jest.mock('@boldcommerce/checkout-frontend-library/lib/walletPay/walletPayOnShipping');
jest.mock('src/actions/displayError');
const walletPayOnShippingMock = mocked(walletPayOnShipping, true);
const displayErrorMock = mocked(displayError, true);

describe('testing ppcpOnShippingChange function', () => {

Expand Down Expand Up @@ -52,7 +49,7 @@ describe('testing ppcpOnShippingChange function', () => {

await ppcpOnShippingChange(dataMock, actionMock);
expect(walletPayOnShippingMock).toHaveBeenCalledTimes(1);
expect(displayErrorMock).toHaveBeenCalledTimes(0);
expect(actionMock.reject).toHaveBeenCalledTimes(0);
});


Expand All @@ -62,8 +59,7 @@ describe('testing ppcpOnShippingChange function', () => {
walletPayOnShippingMock.mockReturnValue(Promise.resolve(paymentReturn));

await ppcpOnShippingChange(dataMock, actionMock);
expect(displayErrorMock).toHaveBeenCalledTimes(1);
expect(displayErrorMock).toHaveBeenCalledWith('There was an unknown error while getting the shipping details.', 'payment_gateway', 'unknown_error');
expect(walletPayOnShippingMock).toHaveBeenCalledTimes(1);
expect(actionMock.reject).toHaveBeenCalledTimes(1);
});

Expand Down

0 comments on commit cebc545

Please sign in to comment.