A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/ui/components/app/modals/confirm-delete-network/confirm-delete-network.test.js

52 lines
1.5 KiB

import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import configureMockStore from 'redux-mock-store';
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
import mockState from '../../../../../test/data/mock-state.json';
import ConfirmDeleteNetwork from '.';
describe('Confirm Delete Network', () => {
const props = {
hideModal: jest.fn(),
onConfirm: jest.fn(),
delRpcTarget: jest.fn().mockResolvedValue(),
target: 'target',
};
it('should match snapshot', () => {
const mockStore = configureMockStore()(mockState);
const { container } = renderWithProvider(
<ConfirmDeleteNetwork {...props} />,
mockStore,
);
expect(container).toMatchSnapshot();
});
it('clicks cancel to hide modal', async () => {
const { queryByText } = renderWithProvider(
<ConfirmDeleteNetwork.WrappedComponent {...props} />,
);
fireEvent.click(queryByText('[cancel]'));
expect(props.delRpcTarget).not.toHaveBeenCalled();
expect(props.onConfirm).not.toHaveBeenCalled();
expect(props.hideModal).toHaveBeenCalled();
});
it('clicks delete to delete the target and hides modal', async () => {
const { queryByText } = renderWithProvider(
<ConfirmDeleteNetwork.WrappedComponent {...props} />,
);
fireEvent.click(queryByText('[delete]'));
await waitFor(() => {
expect(props.delRpcTarget).toHaveBeenCalled();
expect(props.onConfirm).toHaveBeenCalled();
expect(props.hideModal).toHaveBeenCalled();
});
});
});