-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filtering out payment method before actually creating it
- Loading branch information
1 parent
03572cb
commit 3a38e02
Showing
4 changed files
with
58 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@adyen/adyen-web': patch | ||
--- | ||
|
||
Dropin: Filtering out payment method type before creating the payment method element |
44 changes: 44 additions & 0 deletions
44
packages/lib/src/components/Dropin/elements/createElements.test.ts
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,44 @@ | ||
import createElements from './createElements'; | ||
import Card from '../../Card/Card'; | ||
|
||
import type { PaymentMethod } from '../../../types/global-types'; | ||
import type { ICore } from '../../../core/types'; | ||
import type { _MockProxy } from 'jest-mock-extended/lib/Mock'; | ||
|
||
describe('Drop-in: createElements', () => { | ||
test('should filter out non-supported payment methods before attempting to create the payment method components', async () => { | ||
const paymentMethods: PaymentMethod[] = [ | ||
{ | ||
type: 'scheme', | ||
name: 'Cards', | ||
brands: [] | ||
}, | ||
{ | ||
type: 'clicktopay', | ||
name: 'Click to Pay', | ||
configuration: { | ||
visaSrcInitiatorId: 'B9SECVKI...', | ||
visaSrciDpaId: '8e6e347c-25...' | ||
} | ||
}, | ||
{ | ||
type: 'androidpay', | ||
name: 'AndroidPay' | ||
} | ||
]; | ||
|
||
const core = global.core as _MockProxy<ICore> & ICore; | ||
core.getComponent.mockImplementation((type: string) => { | ||
if (type === 'scheme') { | ||
return Card; | ||
} | ||
}); | ||
|
||
const elements = await createElements(paymentMethods, {}, {}, core); | ||
|
||
expect(core.getComponent).toHaveBeenCalledTimes(1); | ||
expect(core.getComponent).toHaveBeenCalledWith('scheme'); | ||
expect(elements.length).toBe(1); | ||
expect(elements[0]).toBeInstanceOf(Card); | ||
}); | ||
}); |
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