1 // import { fireEvent, waitFor } from '@testing-library/react';
3 // import { Autopay, CardModel } from '@proton/payments';
4 // import { updatePaymentMethod } from '@proton/shared/lib/api/payments';
10 // withDeprecatedModals,
13 // } from '@proton/testing';
15 // import { renderWithProviders } from '../contacts/tests/render';
16 // import EditCardModal from './EditCardModal';
18 // jest.mock('@proton/components/components/portal/Portal');
19 // jest.mock('@proton/components/components/toggle/Toggle');
21 // const defaultCard: CardModel = {
31 // jest.clearAllMocks();
34 // const ContextEditCardModal = applyHOCs(
35 // withNotifications(),
36 // withEventManager(),
39 // withDeprecatedModals()
42 // it('should render', () => {
43 // const { container } = renderWithProviders(<ContextEditCardModal open={true} />);
45 // expect(container).not.toBeEmptyDOMElement();
48 // it('should update Autopay and close modal if user edits the existing payment method', async () => {
49 // const paymentMethodId = 'paymentMethodId123';
50 // const onClose = jest.fn();
51 // const { getByTestId } = renderWithProviders(
52 // <ContextEditCardModal
54 // renewState={Autopay.DISABLE}
55 // paymentMethodId={paymentMethodId}
61 // fireEvent.click(getByTestId('toggle-subscription-renew'));
63 // await waitFor(() => {
64 // expect(apiMock).toHaveBeenCalledWith(updatePaymentMethod(paymentMethodId, { Autopay: Autopay.ENABLE }));
66 // await waitFor(() => {
67 // expect(onClose).toHaveBeenCalled();
71 // it('should update Autopay and close modal if user edits the existing payment method (toggle off)', async () => {
72 // const paymentMethodId = 'paymentMethodId123';
73 // const onClose = jest.fn();
74 // const { getByTestId } = renderWithProviders(
75 // <ContextEditCardModal
77 // renewState={Autopay.ENABLE}
78 // paymentMethodId={paymentMethodId}
84 // fireEvent.click(getByTestId('toggle-subscription-renew'));
85 // fireEvent.click(getByTestId('action-disable-autopay'));
87 // await waitFor(() => {
88 // expect(apiMock).toHaveBeenCalledWith(updatePaymentMethod(paymentMethodId, { Autopay: Autopay.DISABLE }));
90 // await waitFor(() => {
91 // expect(onClose).toHaveBeenCalled();
95 // it('should not update autopay if this is Add Credit card mode', async () => {
96 // const onClose = jest.fn();
97 // const { getByTestId } = renderWithProviders(<ContextEditCardModal open={true} onClose={onClose} />);
99 // fireEvent.click(getByTestId('toggle-subscription-renew'));
100 // fireEvent.click(getByTestId('action-disable-autopay'));
102 // await waitFor(() => {});
104 // expect(apiMock).not.toHaveBeenCalled();
105 // expect(onClose).not.toHaveBeenCalled();
108 // it('should toggle back if API returned error', async () => {
109 // apiMock.mockRejectedValue(new Error());
111 // const paymentMethodId = 'paymentMethodId123';
112 // const onClose = jest.fn();
113 // const { getByTestId } = renderWithProviders(
114 // <ContextEditCardModal
115 // card={defaultCard}
116 // renewState={Autopay.DISABLE}
117 // paymentMethodId={paymentMethodId}
123 // fireEvent.click(getByTestId('toggle-subscription-renew'));
125 // await waitFor(() => {
126 // expect(apiMock).toHaveBeenCalledWith(updatePaymentMethod(paymentMethodId, { Autopay: Autopay.ENABLE }));
128 // await waitFor(() => {
129 // expect(onClose).not.toHaveBeenCalled();
131 // await waitFor(() => {
132 // expect(getByTestId('toggle-subscription-renew')).not.toHaveTextContent('CHECKED');
136 // it('should disable Save button while updating the toggle status', async () => {
137 // let resolve!: () => void;
138 // const manualPromise = new Promise<void>((innerResolve) => (resolve = innerResolve));
139 // apiMock.mockReturnValue(manualPromise);
141 // const paymentMethodId = 'paymentMethodId123';
142 // const onClose = jest.fn();
143 // const { getByTestId } = renderWithProviders(
144 // <ContextEditCardModal
145 // card={defaultCard}
146 // renewState={Autopay.DISABLE}
147 // paymentMethodId={paymentMethodId}
153 // fireEvent.click(getByTestId('toggle-subscription-renew'));
154 // await waitFor(() => {
155 // expect(getByTestId('edit-card-action-save')).toHaveAttribute('disabled');
159 // await waitFor(() => {
160 // expect(getByTestId('edit-card-action-save')).not.toHaveAttribute('disabled');
164 it('placeholder', () => expect(true).toBeTruthy());