2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2022-10-11 19:54:50 +02:00
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import { fireEvent } from '@testing-library/react';
|
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
2021-03-16 22:00:08 +01:00
|
|
|
import RevealSeedPage from './reveal-seed';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
const mockRequestRevealSeedWords = jest.fn().mockResolvedValue();
|
|
|
|
|
|
|
|
jest.mock('../../store/actions.js', () => ({
|
|
|
|
requestRevealSeedWords: () => mockRequestRevealSeedWords,
|
|
|
|
}));
|
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Reveal Seed Page', () => {
|
2022-10-11 19:54:50 +02:00
|
|
|
const mockState = {
|
|
|
|
history: {
|
2021-04-15 20:01:46 +02:00
|
|
|
mostRecentOverviewPage: '/',
|
2022-10-11 19:54:50 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
|
|
|
|
|
|
|
it('should match snapshot', () => {
|
|
|
|
const { container } = renderWithProvider(<RevealSeedPage />, mockStore);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('form submit', () => {
|
|
|
|
const { queryByTestId, queryByText } = renderWithProvider(
|
|
|
|
<RevealSeedPage />,
|
|
|
|
mockStore,
|
|
|
|
);
|
|
|
|
|
|
|
|
fireEvent.change(queryByTestId('input-password'), {
|
|
|
|
target: { value: 'password' },
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-10-11 19:54:50 +02:00
|
|
|
fireEvent.click(queryByText('Next'));
|
|
|
|
|
|
|
|
expect(mockRequestRevealSeedWords).toHaveBeenCalled();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|