1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 15:50:28 +01:00
metamask-extension/ui/components/app/modals/confirm-remove-account/confirm-remove-account.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

73 lines
1.9 KiB
JavaScript

import React from 'react';
import configureMockStore from 'redux-mock-store';
import { fireEvent } from '@testing-library/react';
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
import ConfirmRemoveAccount from '.';
describe('Confirm Remove Account', () => {
const state = {
metamask: {
providerConfig: {
chainId: '0x99',
},
},
};
const props = {
hideModal: jest.fn(),
removeAccount: jest.fn().mockResolvedValue(),
identity: {
address: '0x0',
name: 'Account 1',
},
chainId: '0x99',
rpcPrefs: {},
};
const mockStore = configureMockStore()(state);
it('should match snapshot', () => {
const { container } = renderWithProvider(
<ConfirmRemoveAccount.WrappedComponent {...props} />,
mockStore,
);
expect(container).toMatchSnapshot();
});
it('should only hide modal when clicking "Nevermind"', () => {
const { queryByText } = renderWithProvider(
<ConfirmRemoveAccount.WrappedComponent {...props} />,
mockStore,
);
fireEvent.click(queryByText('Nevermind'));
expect(props.removeAccount).not.toHaveBeenCalled();
expect(props.hideModal).toHaveBeenCalled();
});
it('should call remove account with identity address', async () => {
const { queryByText } = renderWithProvider(
<ConfirmRemoveAccount.WrappedComponent {...props} />,
mockStore,
);
fireEvent.click(queryByText('Remove'));
expect(props.removeAccount).toHaveBeenCalledWith(props.identity.address);
expect(props.hideModal).toHaveBeenCalled();
});
it('should close modal when clicking close from the header', () => {
const { queryByTestId } = renderWithProvider(
<ConfirmRemoveAccount.WrappedComponent {...props} />,
mockStore,
);
fireEvent.click(queryByTestId('modal-header-close'));
expect(props.hideModal).toHaveBeenCalled();
});
});