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-remove-account/confirm-remove-account.test.js

83 lines
1.8 KiB

import React from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import sinon from 'sinon';
import configureStore from 'redux-mock-store';
import { mount } from 'enzyme';
import ConfirmRemoveAccount from './confirm-remove-account.container';
describe('Confirm Remove Account', () => {
let wrapper;
const state = {
metamask: {
provider: {
chainId: '0x0',
},
},
};
const props = {
hideModal: sinon.spy(),
removeAccount: sinon.stub().resolves(),
network: '101',
identity: {
address: '0x0',
name: 'Account 1',
},
chainId: '0x0',
rpcPrefs: {},
};
const mockStore = configureStore();
const store = mockStore(state);
beforeEach(() => {
wrapper = mount(
<Provider store={store}>
<ConfirmRemoveAccount.WrappedComponent {...props} />
</Provider>,
{
context: {
t: (str) => str,
store,
},
childContextTypes: {
t: PropTypes.func,
store: PropTypes.object,
},
},
);
});
afterEach(() => {
props.hideModal.resetHistory();
});
it('nevermind', () => {
const nevermind = wrapper.find({ type: 'secondary' });
nevermind.simulate('click');
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
it('remove', async () => {
const remove = wrapper.find({ type: 'primary' });
remove.simulate('click');
expect(await props.removeAccount.calledOnce).toStrictEqual(true);
expect(props.removeAccount.getCall(0).args[0]).toStrictEqual(
props.identity.address,
);
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
it('closes', () => {
const close = wrapper.find('.modal-container__header-close');
close.simulate('click');
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
});