1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 07:24:56 +01:00
metamask-extension/ui/components/app/modals/confirm-delete-network/confirm-delete-network.test.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
import sinon from 'sinon';
import { mount } from 'enzyme';
import ConfirmDeleteNetwork from './confirm-delete-network.container';
describe('Confirm Delete Network', () => {
let wrapper;
const props = {
hideModal: sinon.spy(),
delRpcTarget: sinon.stub().resolves(),
onConfirm: sinon.spy(),
target: '',
};
beforeEach(() => {
2020-11-03 00:41:28 +01:00
wrapper = mount(<ConfirmDeleteNetwork.WrappedComponent {...props} />, {
context: {
t: (str) => str,
},
});
});
afterEach(() => {
props.hideModal.resetHistory();
props.delRpcTarget.resetHistory();
props.onConfirm.resetHistory();
});
it('renders delete network modal title', () => {
const modalTitle = wrapper.find('.modal-content__title');
expect(modalTitle.text()).toStrictEqual('deleteNetwork');
});
it('clicks cancel to hide modal', () => {
2020-11-03 00:41:28 +01:00
const cancelButton = wrapper.find(
'.button.btn-default.modal-container__footer-button',
);
cancelButton.simulate('click');
expect(props.hideModal.calledOnce).toStrictEqual(true);
});
it('clicks delete to delete the target and hides modal', async () => {
2020-11-03 00:41:28 +01:00
const deleteButton = wrapper.find(
'.button.btn-danger.modal-container__footer-button',
);
deleteButton.simulate('click');
expect(await props.delRpcTarget.calledOnce).toStrictEqual(true);
expect(props.hideModal.calledOnce).toStrictEqual(true);
expect(props.onConfirm.calledOnce).toStrictEqual(true);
});
});