Skip to content

Commit

Permalink
Fixing jest component test output errors (#11139)
Browse files Browse the repository at this point in the history
* Adding missing required props to component tests

* Removing unused IntroPopup component

* Mocking useLayoutEffect as useEffect in confirm-page-container-header.component.test.js
  • Loading branch information
ryanml authored May 20, 2021
1 parent 2972e78 commit 6640973
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import ConfirmPageContainerHeader from './confirm-page-container-header.componen

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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('AdvancedTabContent Component', () => {
insufficientBalance={false}
customPriceIsSafe
isSpeedUp={false}
customPriceIsExcessive={false}
/>,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('GasModalPageContainer Component', () => {
customGasLimitInHex="mockCustomGasLimitInHex"
insufficientBalance={false}
disableSave={false}
customPriceIsExcessive={false}
/>,
);
});
Expand Down Expand Up @@ -124,6 +125,7 @@ describe('GasModalPageContainer Component', () => {
<GasModalPageContainer
fetchBasicGasEstimates={propsMethodSpies.fetchBasicGasEstimates}
fetchGasEstimates={propsMethodSpies.fetchGasEstimates}
customPriceIsExcessive={false}
/>,
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
);
Expand Down Expand Up @@ -202,6 +204,7 @@ describe('GasModalPageContainer Component', () => {
customGasLimitInHex="mockCustomGasLimitInHex"
insufficientBalance={false}
disableSave={false}
customPriceIsExcessive={false}
hideBasic
/>,
);
Expand Down
25 changes: 17 additions & 8 deletions ui/components/app/menu-bar/menu-bar.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { waitFor } from '@testing-library/react';
import { mountWithRouter } from '../../../../test/lib/render-helpers';
import { ROPSTEN_CHAIN_ID } from '../../../../shared/constants/network';
import MenuBar from './menu-bar';
Expand Down Expand Up @@ -30,21 +31,25 @@ const initState = {
const mockStore = configureStore();

describe('MenuBar', () => {
it('opens account detail menu when account options is clicked', () => {
it('opens account detail menu when account options is clicked', async () => {
const store = mockStore(initState);
const wrapper = mountWithRouter(
<Provider store={store}>
<MenuBar />
</Provider>,
);
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
await waitFor(() =>
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true),
);
const accountOptions = wrapper.find('.menu-bar__account-options');
accountOptions.simulate('click');
wrapper.update();
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
await waitFor(() =>
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true),
);
});

it('sets accountDetailsMenuOpen to false when closed', () => {
it('sets accountDetailsMenuOpen to false when closed', async () => {
const store = mockStore(initState);
const wrapper = mountWithRouter(
<Provider store={store}>
Expand All @@ -54,10 +59,14 @@ describe('MenuBar', () => {
const accountOptions = wrapper.find('.menu-bar__account-options');
accountOptions.simulate('click');
wrapper.update();
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
await waitFor(() =>
expect(wrapper.exists('AccountOptionsMenu')).toStrictEqual(true),
);
const accountDetailsMenu = wrapper.find('AccountOptionsMenu');
accountDetailsMenu.prop('onClose')();
wrapper.update();
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
await waitFor(() => {
accountDetailsMenu.prop('onClose')();
wrapper.update();
expect(!wrapper.exists('AccountOptionsMenu')).toStrictEqual(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('Confirm Remove Account', () => {
address: '0x0',
name: 'Account 1',
},
chainId: '0x0',
rpcPrefs: {},
};

const mockStore = configureStore();
Expand Down
7 changes: 6 additions & 1 deletion ui/pages/send/send-content/send-content.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import SendAssetRow from './send-asset-row/send-asset-row.container';
describe('SendContent Component', () => {
let wrapper;

const defaultProps = {
showHexData: true,
gasIsExcessive: false,
};

beforeEach(() => {
wrapper = shallow(<SendContent showHexData />, {
wrapper = shallow(<SendContent {...defaultProps} />, {
context: { t: (str) => `${str}_t` },
});
});
Expand Down
8 changes: 8 additions & 0 deletions ui/pages/settings/advanced-tab/advanced-tab.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ describe('AdvancedTab Component', () => {
setThreeBoxSyncingPermission={() => undefined}
threeBoxDisabled
threeBoxSyncingAllowed={false}
useLedgerLive={false}
setLedgerLivePreference={() => undefined}
setDismissSeedBackUpReminder={() => undefined}
dismissSeedBackUpReminder={false}
/>,
{
context: {
Expand All @@ -37,6 +41,10 @@ describe('AdvancedTab Component', () => {
setThreeBoxSyncingPermission={() => undefined}
threeBoxDisabled
threeBoxSyncingAllowed={false}
useLedgerLive={false}
setLedgerLivePreference={() => undefined}
setDismissSeedBackUpReminder={() => undefined}
dismissSeedBackUpReminder={false}
/>,
{
context: {
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion ui/pages/swaps/intro-popup/index.js

This file was deleted.

71 changes: 0 additions & 71 deletions ui/pages/swaps/intro-popup/index.scss

This file was deleted.

108 changes: 0 additions & 108 deletions ui/pages/swaps/intro-popup/intro-popup.js

This file was deleted.

24 changes: 0 additions & 24 deletions ui/pages/swaps/intro-popup/intro-popup.test.js

This file was deleted.

0 comments on commit 6640973

Please sign in to comment.