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

77 lines
1.8 KiB
JavaScript
Raw Normal View History

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 = {
2020-11-03 00:41:28 +01:00
metamask: {},
};
const props = {
hideModal: sinon.spy(),
removeAccount: sinon.stub().resolves(),
network: '101',
identity: {
2021-04-16 17:05:13 +02:00
address: '0x0',
name: 'Account 1',
},
};
const mockStore = configureStore();
const store = mockStore(state);
beforeEach(() => {
wrapper = mount(
2020-11-03 00:41:28 +01:00
<Provider store={store}>
<ConfirmRemoveAccount.WrappedComponent {...props} />
2020-11-03 00:41:28 +01:00
</Provider>,
{
context: {
2020-02-15 21:34:12 +01:00
t: (str) => str,
store,
},
childContextTypes: {
t: PropTypes.func,
store: PropTypes.object,
},
},
);
});
afterEach(() => {
props.hideModal.resetHistory();
});
it('nevermind', () => {
const nevermind = wrapper.find({ type: 'default' });
nevermind.simulate('click');
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
it('remove', async () => {
const remove = wrapper.find({ type: 'secondary' });
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);
});
});