1 import { render } from '@testing-library/react';
3 import { PAYMENT_METHOD_TYPES } from '@proton/payments';
4 import type { CardPayment, PaypalPayment } from '@proton/payments';
6 import PaymentVerificationImage from './PaymentVerificationImage';
8 describe('PaymentVerificationImage', () => {
9 it.each([PAYMENT_METHOD_TYPES.PAYPAL, PAYMENT_METHOD_TYPES.PAYPAL_CREDIT])(
10 'should render paypal image. Payment method: %s',
12 const payment: PaypalPayment = {
16 const { getByAltText } = render(<PaymentVerificationImage payment={payment} type={Type as any} />);
18 expect(getByAltText('PayPal')).toBeDefined();
22 it('should render Paypal if payment object is empty but the type is defined', () => {
23 const { getByAltText } = render(<PaymentVerificationImage payment={{}} type={PAYMENT_METHOD_TYPES.PAYPAL} />);
25 expect(getByAltText('PayPal')).toBeDefined();
28 it('should render image for the respective credit card', () => {
29 const payment: CardPayment = {
30 Type: PAYMENT_METHOD_TYPES.CARD,
32 Number: '4242424242424242',
36 const { getByAltText } = render(
37 <PaymentVerificationImage payment={payment} type={PAYMENT_METHOD_TYPES.CARD} />
40 expect(getByAltText('Visa')).toBeDefined();
43 it('should render nothing if payment is empty and type is card', () => {
44 const { container } = render(<PaymentVerificationImage payment={{}} type={PAYMENT_METHOD_TYPES.CARD} />);
46 expect(container).toBeEmptyDOMElement();