-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: jest mock file * chore: add jest folder to the whitelist * chore: update docs * chore: better components mocks, rename mock file Co-authored-by: Arkadiusz Kubaczkowski <arek.kubaczkowski@callstak.com>
- Loading branch information
1 parent
0de7e64
commit c1681a0
Showing
4 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
const mockFunctions = { | ||
createPaymentMethod: jest.fn(async () => ({ | ||
paymentMethod: {}, | ||
error: null, | ||
})), | ||
createToken: jest.fn(async () => ({ | ||
token: {}, | ||
error: null, | ||
})), | ||
retrievePaymentIntent: jest.fn(async () => ({ | ||
paymentIntent: {}, | ||
error: null, | ||
})), | ||
retrieveSetupIntent: jest.fn(async () => ({ | ||
setupIntent: {}, | ||
error: null, | ||
})), | ||
confirmPayment: jest.fn(async () => ({ | ||
paymentMethod: {}, | ||
error: null, | ||
})), | ||
isApplePaySupported: jest.fn(async () => true), | ||
presentApplePay: jest.fn(async () => ({ | ||
error: null, | ||
})), | ||
updateApplePaySummaryItems: jest.fn(async () => ({})), | ||
confirmApplePayPayment: jest.fn(async () => ({})), | ||
handleCardAction: jest.fn(async () => ({ | ||
paymentIntent: {}, | ||
error: null, | ||
})), | ||
confirmSetupIntent: jest.fn(async () => ({ | ||
setupIntent: {}, | ||
error: null, | ||
})), | ||
createTokenForCVCUpdate: jest.fn(async () => ({ | ||
tokenId: '123', | ||
error: null, | ||
})), | ||
handleURLCallback: jest.fn(async () => true), | ||
presentPaymentSheet: jest.fn(async () => ({ | ||
paymentOption: {}, | ||
error: null, | ||
})), | ||
confirmPaymentSheetPayment: jest.fn(async () => ({ | ||
error: null, | ||
})), | ||
initGooglePay: jest.fn(async () => ({ | ||
error: null, | ||
})), | ||
presentGooglePay: jest.fn(async () => ({ | ||
error: null, | ||
})), | ||
createGooglePayPayment: jest.fn(async () => ({ | ||
paymentMethod: {}, | ||
error: null, | ||
})), | ||
openApplePaySetup: jest.fn(async () => ({ | ||
error: null, | ||
})), | ||
initPaymentSheet: jest.fn(async () => ({ | ||
paymentOption: {}, | ||
error: null, | ||
})), | ||
}; | ||
|
||
const mockHooks = { | ||
useConfirmPayment: jest.fn(() => ({ | ||
confirmPayment: jest.fn(() => ({ | ||
...mockFunctions.confirmPayment(), | ||
})), | ||
})), | ||
useConfirmSetupIntent: jest.fn(() => ({ | ||
confirmSetupIntent: jest.fn(() => ({ | ||
...mockFunctions.confirmSetupIntent(), | ||
})), | ||
})), | ||
useGooglePay: jest.fn(() => ({ | ||
loading: false, | ||
initGooglePay: jest.fn(async () => ({ | ||
...mockFunctions.initGooglePay(), | ||
})), | ||
presentGooglePay: jest.fn(async () => ({ | ||
...mockFunctions.presentGooglePay(), | ||
})), | ||
createGooglePayPaymentMethod: jest.fn(async () => ({ | ||
...mockFunctions.createGooglePayPayment(), | ||
})), | ||
})), | ||
useApplePay: jest.fn(() => ({ | ||
loading: false, | ||
isApplePaySupported: true, | ||
presentApplePay: jest.fn(async () => ({ | ||
...mockFunctions.presentApplePay(), | ||
})), | ||
confirmApplePayPayment: jest.fn(async () => ({ | ||
...mockFunctions.confirmApplePayPayment(), | ||
})), | ||
openApplePaySetup: jest.fn(async () => ({ | ||
...mockFunctions.openApplePaySetup(), | ||
})), | ||
})), | ||
usePaymentSheet: jest.fn(() => ({ | ||
loading: false, | ||
initPaymentSheet: jest.fn(async () => ({ | ||
...mockFunctions.initPaymentSheet(), | ||
})), | ||
presentPaymentSheet: jest.fn(async () => ({ | ||
...mockFunctions.presentPaymentSheet(), | ||
})), | ||
confirmPaymentSheetPayment: jest.fn(async () => ({ | ||
...mockFunctions.confirmPaymentSheetPayment(), | ||
})), | ||
})), | ||
}; | ||
|
||
module.exports = { | ||
...mockFunctions, | ||
...mockHooks, | ||
StripeProvider: () => 'StripeProvider', | ||
CardField: () => 'CardField', | ||
ApplePayButton: () => 'ApplePayButton', | ||
AuBECSDebitForm: () => 'AuBECSDebitForm', | ||
GooglePayButton: () => 'GooglePayButton', | ||
useStripe: jest.fn(() => mockHooks), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters