Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / containers / payments / Checkout.test.tsx
blob039d03d5b0a9a010cc27dc1ac9f54cb4add8661a
1 import { render, screen } from '@testing-library/react';
3 import { type AvailablePaymentMethod, PAYMENT_METHOD_TYPES } from '@proton/payments';
4 import { buildUser } from '@proton/testing/builders';
6 import { type MethodsHook } from '../../payments/react-extensions';
7 import Checkout, { type Props } from './Checkout';
9 let props: Props;
10 beforeEach(() => {
11     props = {
12         currencies: [],
13         currency: 'EUR',
14         onChangeCurrency: jest.fn(),
15         children: <div>children</div>,
16         renewNotice: <div>renewNotice</div>,
17         user: buildUser(),
18         planIDs: {},
19         paymentMethods: {
20             selectedMethod: undefined,
21             allMethods: [],
22             loading: false,
23             usedMethods: [],
24             newMethods: [],
25             lastUsedMethod: undefined,
26             savedInternalSelectedMethod: undefined,
27             savedExternalSelectedMethod: undefined,
28             savedSelectedMethod: undefined,
29             selectMethod: jest.fn(),
30             getSavedMethodByID: jest.fn(),
31             status: undefined,
32             savedMethods: undefined,
33             isNewPaypal: false,
34             isMethodTypeEnabled: jest.fn(),
35         } as MethodsHook,
36     };
37 });
39 it('should render', () => {
40     render(<Checkout {...props} />);
42     expect(screen.getByText('Summary')).toBeInTheDocument();
43 });
45 it('should disable currency selector when loading', () => {
46     render(<Checkout {...props} loading={true} />);
48     expect(screen.getByTestId('currency-selector')).toBeDisabled();
49 });
51 it('should disable currency selector when selected method is SEPA', () => {
52     props.paymentMethods.selectedMethod = {
53         type: PAYMENT_METHOD_TYPES.CHARGEBEE_SEPA_DIRECT_DEBIT,
54         value: 'SEPA',
55         isSaved: false,
56     } as AvailablePaymentMethod;
58     render(<Checkout {...props} />);
60     expect(screen.getByTestId('currency-selector')).toBeDisabled();
61 });