mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
d1cea85f33
* Rename `provider` to `providerConfig` The network controller `provider` state has been renamed to `providerConfig`. This better reflects what this state is, and makes this controller more closely aligned with the core network controller. All references to the provider configuration have been updated to prefer `providerConfig` over `provider`, to make the distinction clear between a provider and provider config. Closes #18902 * Add migration
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
import React from 'react';
|
|
import { fireEvent } from '@testing-library/react';
|
|
import configureMockStore from 'redux-mock-store';
|
|
import thunk from 'redux-thunk';
|
|
import {
|
|
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
|
|
ONBOARDING_PIN_EXTENSION_ROUTE,
|
|
} from '../../../helpers/constants/routes';
|
|
import {
|
|
renderWithProvider,
|
|
setBackgroundConnection,
|
|
} from '../../../../test/jest';
|
|
import CreationSuccessful from './creation-successful';
|
|
|
|
const mockHistoryPush = jest.fn();
|
|
|
|
const completeOnboardingStub = jest
|
|
.fn()
|
|
.mockImplementation(() => Promise.resolve());
|
|
|
|
jest.mock('react-router-dom', () => ({
|
|
...jest.requireActual('react-router-dom'),
|
|
useHistory: () => ({
|
|
push: mockHistoryPush,
|
|
}),
|
|
}));
|
|
|
|
describe('Creation Successful Onboarding View', () => {
|
|
const mockStore = {
|
|
metamask: {
|
|
providerConfig: {
|
|
type: 'test',
|
|
},
|
|
},
|
|
};
|
|
const store = configureMockStore([thunk])(mockStore);
|
|
setBackgroundConnection({ completeOnboarding: completeOnboardingStub });
|
|
|
|
afterEach(() => {
|
|
jest.resetAllMocks();
|
|
});
|
|
|
|
it('should redirect to privacy-settings view when "Advanced configuration" button is clicked', () => {
|
|
const { getByText } = renderWithProvider(<CreationSuccessful />, store);
|
|
const privacySettingsButton = getByText('Advanced configuration');
|
|
fireEvent.click(privacySettingsButton);
|
|
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,
|
|
);
|
|
});
|
|
});
|