2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2022-09-28 16:43:13 +02:00
|
|
|
import { fireEvent } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
|
|
|
|
import ConfirmResetAccount from '.';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Confirm Reset Account', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
2022-09-28 16:43:13 +02:00
|
|
|
hideModal: jest.fn(),
|
|
|
|
resetAccount: jest.fn().mockResolvedValue(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-28 16:43:13 +02:00
|
|
|
it('should match snapshot', () => {
|
|
|
|
const { container } = renderWithProvider(
|
|
|
|
<ConfirmResetAccount.WrappedComponent {...props} />,
|
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-28 16:43:13 +02:00
|
|
|
expect(container).toMatchSnapshot();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('hides modal when nevermind button is clicked', () => {
|
2022-09-28 16:43:13 +02:00
|
|
|
const { queryByText } = renderWithProvider(
|
|
|
|
<ConfirmResetAccount.WrappedComponent {...props} />,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-28 16:43:13 +02:00
|
|
|
fireEvent.click(queryByText('[nevermind]'));
|
|
|
|
|
|
|
|
expect(props.resetAccount).not.toHaveBeenCalled();
|
|
|
|
expect(props.hideModal).toHaveBeenCalled();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('resets account and hides modal when reset button is clicked', async () => {
|
2022-09-28 16:43:13 +02:00
|
|
|
const { queryByText } = renderWithProvider(
|
|
|
|
<ConfirmResetAccount.WrappedComponent {...props} />,
|
2021-10-05 21:20:42 +02:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2023-02-10 22:50:12 +01:00
|
|
|
fireEvent.click(queryByText('[clear]'));
|
2022-09-28 16:43:13 +02:00
|
|
|
|
|
|
|
expect(props.resetAccount).toHaveBeenCalled();
|
|
|
|
expect(props.hideModal).toHaveBeenCalled();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|