2021-10-11 16:43:25 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { fireEvent } from '@testing-library/react';
|
2021-10-15 20:52:52 +02:00
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import thunk from 'redux-thunk';
|
2023-04-20 19:51:51 +02:00
|
|
|
import {
|
|
|
|
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
|
|
|
|
ONBOARDING_PIN_EXTENSION_ROUTE,
|
|
|
|
} from '../../../helpers/constants/routes';
|
2021-10-11 16:43:25 +02:00
|
|
|
import {
|
2021-10-15 20:52:52 +02:00
|
|
|
renderWithProvider,
|
|
|
|
setBackgroundConnection,
|
|
|
|
} from '../../../../test/jest';
|
2021-10-11 16:43:25 +02:00
|
|
|
import CreationSuccessful from './creation-successful';
|
|
|
|
|
2023-04-20 19:51:51 +02:00
|
|
|
const mockHistoryPush = jest.fn();
|
|
|
|
|
2021-10-15 20:52:52 +02:00
|
|
|
const completeOnboardingStub = jest
|
|
|
|
.fn()
|
|
|
|
.mockImplementation(() => Promise.resolve());
|
|
|
|
|
2023-04-20 19:51:51 +02:00
|
|
|
jest.mock('react-router-dom', () => ({
|
|
|
|
...jest.requireActual('react-router-dom'),
|
|
|
|
useHistory: () => ({
|
|
|
|
push: mockHistoryPush,
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
|
2021-10-11 16:43:25 +02:00
|
|
|
describe('Creation Successful Onboarding View', () => {
|
2021-10-15 20:52:52 +02:00
|
|
|
const mockStore = {
|
|
|
|
metamask: {
|
2023-05-02 17:53:20 +02:00
|
|
|
providerConfig: {
|
2021-10-15 20:52:52 +02:00
|
|
|
type: 'test',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const store = configureMockStore([thunk])(mockStore);
|
|
|
|
setBackgroundConnection({ completeOnboarding: completeOnboardingStub });
|
|
|
|
|
2023-04-20 19:51:51 +02:00
|
|
|
afterEach(() => {
|
|
|
|
jest.resetAllMocks();
|
2021-10-11 16:43:25 +02:00
|
|
|
});
|
|
|
|
|
2022-12-08 15:20:59 +01:00
|
|
|
it('should redirect to privacy-settings view when "Advanced configuration" button is clicked', () => {
|
2021-10-15 20:52:52 +02:00
|
|
|
const { getByText } = renderWithProvider(<CreationSuccessful />, store);
|
2022-12-08 15:20:59 +01:00
|
|
|
const privacySettingsButton = getByText('Advanced configuration');
|
2021-10-11 16:43:25 +02:00
|
|
|
fireEvent.click(privacySettingsButton);
|
2023-04-20 19:51:51 +02:00
|
|
|
expect(mockHistoryPush).toHaveBeenCalledWith(
|
|
|
|
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should route to pin extension route when "Got it" button is clicked', () => {
|
|
|
|
const { getByText } = renderWithProvider(<CreationSuccessful />, store);
|
|
|
|
const gotItButton = getByText('Got it!');
|
|
|
|
fireEvent.click(gotItButton);
|
|
|
|
expect(mockHistoryPush).toHaveBeenCalledWith(
|
|
|
|
ONBOARDING_PIN_EXTENSION_ROUTE,
|
|
|
|
);
|
2021-10-11 16:43:25 +02:00
|
|
|
});
|
|
|
|
});
|