2021-02-04 19:15:23 +01:00
|
|
|
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';
|
2021-03-16 22:00:08 +01:00
|
|
|
import ConfirmRemoveAccount from './confirm-remove-account.container';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('Confirm Remove Account', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const state = {
|
2020-11-03 00:41:28 +01:00
|
|
|
metamask: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const props = {
|
|
|
|
hideModal: sinon.spy(),
|
|
|
|
removeAccount: sinon.stub().resolves(),
|
|
|
|
network: '101',
|
|
|
|
identity: {
|
2021-04-16 17:05:13 +02:00
|
|
|
address: '0x0',
|
2020-01-30 20:34:45 +01:00
|
|
|
name: 'Account 1',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const mockStore = configureStore();
|
|
|
|
const store = mockStore(state);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2020-01-30 20:34:45 +01:00
|
|
|
wrapper = mount(
|
2020-11-03 00:41:28 +01:00
|
|
|
<Provider store={store}>
|
2020-01-30 20:34:45 +01:00
|
|
|
<ConfirmRemoveAccount.WrappedComponent {...props} />
|
2020-11-03 00:41:28 +01:00
|
|
|
</Provider>,
|
|
|
|
{
|
2020-01-30 20:34:45 +01:00
|
|
|
context: {
|
2020-02-15 21:34:12 +01:00
|
|
|
t: (str) => str,
|
2020-01-30 20:34:45 +01:00
|
|
|
store,
|
|
|
|
},
|
|
|
|
childContextTypes: {
|
|
|
|
t: PropTypes.func,
|
|
|
|
store: PropTypes.object,
|
|
|
|
},
|
2020-07-14 17:20:41 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
afterEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
props.hideModal.resetHistory();
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('nevermind', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const nevermind = wrapper.find({ type: 'default' });
|
|
|
|
nevermind.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.hideModal.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('remove', async () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const remove = wrapper.find({ type: 'secondary' });
|
|
|
|
remove.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(await props.removeAccount.calledOnce).toStrictEqual(true);
|
|
|
|
expect(props.removeAccount.getCall(0).args[0]).toStrictEqual(
|
2020-12-03 16:46:22 +01:00
|
|
|
props.identity.address,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.hideModal.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('closes', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const close = wrapper.find('.modal-container__header-close');
|
|
|
|
close.simulate('click');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.hideModal.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|