mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 21:00:13 +01:00
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
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();
|
|
});
|
|
});
|
|
});
|