1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/ui/components/app/modals/confirm-remove-account/confirm-remove-account.test.js

79 lines
1.8 KiB
JavaScript

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: {},
};
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);
});
});