mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 16:18:07 +01:00
6640973858
* Adding missing required props to component tests * Removing unused IntroPopup component * Mocking useLayoutEffect as useEffect in confirm-page-container-header.component.test.js
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
import React from 'react';
|
|
import { shallow } from 'enzyme';
|
|
import sinon from 'sinon';
|
|
import { Provider } from 'react-redux';
|
|
import configureStore from '../../../../store/store';
|
|
import testData from '../../../../../.storybook/test-data';
|
|
import ConfirmPageContainerHeader from './confirm-page-container-header.component';
|
|
|
|
const util = require('../../../../../app/scripts/lib/util');
|
|
|
|
jest.mock('react', () => ({
|
|
...jest.requireActual('react'),
|
|
useLayoutEffect: jest.requireActual('react').useEffect,
|
|
}));
|
|
|
|
describe('Confirm Detail Row Component', () => {
|
|
describe('render', () => {
|
|
it('should render a div with a confirm-page-container-header class', () => {
|
|
const stub = sinon
|
|
.stub(util, 'getEnvironmentType')
|
|
.callsFake(() => 'popup');
|
|
const wrapper = shallow(
|
|
<Provider store={configureStore(testData)}>
|
|
<ConfirmPageContainerHeader
|
|
showEdit={false}
|
|
onEdit={() => {
|
|
// noop
|
|
}}
|
|
showAccountInHeader={false}
|
|
accountAddress="0xmockAccountAddress"
|
|
/>
|
|
</Provider>,
|
|
);
|
|
expect(wrapper.html()).toContain('confirm-page-container-header');
|
|
stub.restore();
|
|
});
|
|
|
|
it('should only render children when fullscreen and showEdit is false', () => {
|
|
const stub = sinon
|
|
.stub(util, 'getEnvironmentType')
|
|
.callsFake(() => 'fullscreen');
|
|
const wrapper = shallow(
|
|
<Provider store={configureStore(testData)}>
|
|
<ConfirmPageContainerHeader
|
|
showEdit={false}
|
|
onEdit={() => {
|
|
// noop
|
|
}}
|
|
showAccountInHeader={false}
|
|
accountAddress="0xmockAccountAddress"
|
|
>
|
|
<div className="nested-test-class" />
|
|
</ConfirmPageContainerHeader>
|
|
</Provider>,
|
|
);
|
|
expect(wrapper.html()).toContain('nested-test-class');
|
|
expect(wrapper.html()).not.toContain('confirm-page-container-header');
|
|
stub.restore();
|
|
});
|
|
});
|
|
});
|