1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/pages/onboarding-flow/pin-extension/pin-extension.test.js
Mark Stacey d1cea85f33
Rename provider to providerConfig (#18907)
* 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
2023-05-02 13:23:20 -02:30

44 lines
1.3 KiB
JavaScript

import React from 'react';
import { fireEvent } from '@testing-library/react';
import reactRouterDom from 'react-router-dom';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import {
renderWithProvider,
setBackgroundConnection,
} from '../../../../test/jest';
import PinExtension from './pin-extension';
const completeOnboardingStub = jest
.fn()
.mockImplementation(() => Promise.resolve());
describe('Creation Successful Onboarding View', () => {
const mockStore = {
metamask: {
providerConfig: {
type: 'test',
},
},
};
const store = configureMockStore([thunk])(mockStore);
setBackgroundConnection({ completeOnboarding: completeOnboardingStub });
const pushMock = jest.fn();
beforeAll(() => {
jest
.spyOn(reactRouterDom, 'useHistory')
.mockImplementation()
.mockReturnValue({ push: pushMock });
});
it('should call completeOnboarding in the background when Done" button is clicked', () => {
const { getByText } = renderWithProvider(<PinExtension />, store);
const nextButton = getByText('Next');
fireEvent.click(nextButton);
const gotItButton = getByText('Done');
fireEvent.click(gotItButton);
expect(completeOnboardingStub).toHaveBeenCalledTimes(1);
});
});