diff --git a/test/data/mock-state.json b/test/data/mock-state.json
index a376803df..963c88d42 100644
--- a/test/data/mock-state.json
+++ b/test/data/mock-state.json
@@ -12,12 +12,15 @@
"previousModalState": {
"name": null
}
- }
+ },
+ "warning": null
},
"history": {
- "mostRecentOverviewPage": "/"
+ "mostRecentOverviewPage": "/mostRecentOverviewPage"
},
"metamask": {
+ "usePhishDetect": true,
+ "participateInMetaMetrics": false,
"gasEstimateType": "fee-market",
"gasFeeEstimates": {
"low": {
@@ -46,6 +49,7 @@
"priorityFeeTrend": "down",
"networkCongestion": 0.90625
},
+ "snaps": [{}],
"preferences": {
"hideZeroBalanceTokens": false,
"showFiatInTestnets": false,
@@ -241,20 +245,6 @@
"unapprovedEncryptionPublicKeyMsgCount": 0,
"unapprovedTypedMessages": {},
"unapprovedTypedMessagesCount": 0,
- "send": {
- "gasLimit": "0x5208",
- "gasPrice": "0xee6b2800",
- "gasTotal": "0x4c65c6294000",
- "tokenBalance": null,
- "from": "0xc42edfcc21ed14dda456aa0756c153f7985d8813",
- "to": "",
- "amount": "1bc16d674ec80000",
- "memo": "",
- "errors": {},
- "maxModeOn": false,
- "editingTransactionId": null,
- "toNickname": ""
- },
"useTokenDetection": true,
"advancedGasFee": {
"maxBaseFee": "75",
@@ -1284,5 +1274,24 @@
"origin": "tmashuang.github.io"
}
]
+ },
+ "send": {
+ "amountMode": "INPUT",
+ "currentTransactionUUID": null,
+ "draftTransactions": {},
+ "eip1559support": false,
+ "gasEstimateIsLoading": true,
+ "gasEstimatePollToken": null,
+ "gasIsSetInModal": false,
+ "gasPriceEstimate": "0x0",
+ "gasLimitMinimum": "0x5208",
+ "gasTotalForLayer1": "0x0",
+ "recipientMode": "CONTACT_LIST",
+ "recipientInput": "",
+ "selectedAccount": {
+ "address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
+ "balance": "0x0"
+ },
+ "stage": "INACTIVE"
}
}
diff --git a/ui/components/ui/dropdown/dropdown.js b/ui/components/ui/dropdown/dropdown.js
index 3a6de0dca..8bfde46ff 100644
--- a/ui/components/ui/dropdown/dropdown.js
+++ b/ui/components/ui/dropdown/dropdown.js
@@ -8,9 +8,10 @@ const Dropdown = ({
disabled = false,
onChange,
options,
- selectedOption = null,
+ selectedOption = '',
style,
title,
+ 'data-testid': dataTestId,
}) => {
const _onChange = useCallback(
(event) => {
@@ -25,6 +26,7 @@ const Dropdown = ({
{
this.context.trackEvent({
category: EVENT.CATEGORIES.ONBOARDING,
diff --git a/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js b/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js
index 7bc9f4355..735dc29fa 100644
--- a/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js
+++ b/ui/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.test.js
@@ -1,11 +1,11 @@
import React from 'react';
import sinon from 'sinon';
-import { mount } from 'enzyme';
-import RevealSeedPhrase from './reveal-seed-phrase.container';
+import { fireEvent } from '@testing-library/react';
+import configureMockStore from 'redux-mock-store';
+import { renderWithProvider } from '../../../../../test/lib/render-helpers';
+import RevealSeedPhrase from '.';
describe('Reveal Secret Recovery Phrase', () => {
- let wrapper;
-
const TEST_SEED =
'debris dizzy just program just float decrease vacant alarm reduce speak stadium';
@@ -18,31 +18,29 @@ describe('Reveal Secret Recovery Phrase', () => {
setCompletedOnboarding: sinon.spy(),
};
- beforeEach(() => {
- wrapper = mount(
, {
- context: {
- t: (str) => str,
- trackEvent: () => undefined,
- },
- });
- });
+ const mockState = {
+ metamask: {},
+ };
- it('secret recovery phrase', () => {
- const seedPhrase = wrapper.find(
- '.reveal-seed-phrase__secret-words--hidden',
+ const mockStore = configureMockStore()(mockState);
+
+ it('should match snapshot', () => {
+ const { container } = renderWithProvider(
+
,
+ mockStore,
);
- expect(seedPhrase).toHaveLength(1);
- expect(seedPhrase.text()).toStrictEqual(TEST_SEED);
+
+ expect(container).toMatchSnapshot();
});
- it('clicks to reveal', () => {
- const reveal = wrapper.find('.reveal-seed-phrase__secret-blocker');
+ it('clicks to reveal shows seed phrase', () => {
+ const { queryByTestId } = renderWithProvider(
+
,
+ mockStore,
+ );
- expect(wrapper.state().isShowingSeedPhrase).toStrictEqual(false);
- reveal.simulate('click');
- expect(wrapper.state().isShowingSeedPhrase).toStrictEqual(true);
+ fireEvent.click(queryByTestId('reveal-seed-blocker'));
- const showSeed = wrapper.find('.reveal-seed-phrase__secret-words');
- expect(showSeed).toHaveLength(1);
+ expect(queryByTestId('showing-seed-phrase')).toBeInTheDocument();
});
});
diff --git a/ui/pages/send/send-footer/__snapshots__/send-footer.test.js.snap b/ui/pages/send/send-footer/__snapshots__/send-footer.test.js.snap
new file mode 100644
index 000000000..3e2b8b8c1
--- /dev/null
+++ b/ui/pages/send/send-footer/__snapshots__/send-footer.test.js.snap
@@ -0,0 +1,55 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`SendFooter Component Component Update should match snapshot when component updated with errors 1`] = `
+
+
+
+`;
+
+exports[`SendFooter Component should match snapshot 1`] = `
+
+
+
+`;
diff --git a/ui/pages/send/send-footer/send-footer.component.test.js b/ui/pages/send/send-footer/send-footer.component.test.js
deleted file mode 100644
index cb2b974e3..000000000
--- a/ui/pages/send/send-footer/send-footer.component.test.js
+++ /dev/null
@@ -1,207 +0,0 @@
-import React from 'react';
-import { shallow } from 'enzyme';
-import sinon from 'sinon';
-import {
- CONFIRM_TRANSACTION_ROUTE,
- DEFAULT_ROUTE,
-} from '../../../helpers/constants/routes';
-import PageContainerFooter from '../../../components/ui/page-container/page-container-footer';
-import { renderWithProvider } from '../../../../test/jest';
-import SendFooter from './send-footer.component';
-
-describe('SendFooter Component', () => {
- let wrapper;
-
- const propsMethodSpies = {
- addToAddressBookIfNew: sinon.spy(),
- cancelTx: sinon.spy(),
- resetSendState: sinon.spy(),
- sign: sinon.spy(),
- update: sinon.spy(),
- mostRecentOverviewPage: '/',
- };
- const historySpies = {
- push: sinon.spy(),
- };
- const MOCK_EVENT = { preventDefault: () => undefined };
-
- const renderShallow = (props) => {
- return shallow(
-
,
- { context: { t: (str) => str, trackEvent: () => ({}) } },
- );
- };
-
- beforeAll(() => {
- sinon.spy(SendFooter.prototype, 'onCancel');
- sinon.spy(SendFooter.prototype, 'onSubmit');
- });
-
- beforeEach(() => {
- wrapper = renderShallow();
- });
-
- afterEach(() => {
- propsMethodSpies.resetSendState.resetHistory();
- propsMethodSpies.cancelTx.resetHistory();
- propsMethodSpies.addToAddressBookIfNew.resetHistory();
- propsMethodSpies.resetSendState.resetHistory();
- propsMethodSpies.sign.resetHistory();
- propsMethodSpies.update.resetHistory();
- historySpies.push.resetHistory();
- SendFooter.prototype.onCancel.resetHistory();
- SendFooter.prototype.onSubmit.resetHistory();
- });
-
- afterAll(() => {
- sinon.restore();
- });
-
- describe('onCancel', () => {
- it('should call resetSendState', () => {
- expect(propsMethodSpies.resetSendState.callCount).toStrictEqual(0);
- wrapper.instance().onCancel();
- expect(propsMethodSpies.resetSendState.callCount).toStrictEqual(1);
- });
-
- it('should call cancelTx', () => {
- expect(propsMethodSpies.cancelTx.callCount).toStrictEqual(0);
- wrapper.instance().onCancel();
- expect(propsMethodSpies.cancelTx.callCount).toStrictEqual(1);
- expect(propsMethodSpies.cancelTx.getCall(0).args[0]?.id).toStrictEqual(
- 'ID',
- );
- });
-
- it('should call history.push', () => {
- expect(historySpies.push.callCount).toStrictEqual(0);
- wrapper.instance().onCancel();
- expect(historySpies.push.callCount).toStrictEqual(1);
- expect(historySpies.push.getCall(0).args[0]).toStrictEqual(
- 'mostRecentOverviewPage',
- );
- });
-
- it('should call history.push with DEFAULT_ROUTE in edit stage', () => {
- wrapper = renderShallow({ sendStage: 'EDIT' });
- expect(historySpies.push.callCount).toStrictEqual(0);
- wrapper.instance().onCancel();
- expect(historySpies.push.callCount).toStrictEqual(1);
- expect(historySpies.push.getCall(0).args[0]).toStrictEqual(DEFAULT_ROUTE);
- });
- });
-
- describe('onSubmit', () => {
- it('should call addToAddressBookIfNew with the correct params', () => {
- wrapper.instance().onSubmit(MOCK_EVENT);
- expect(propsMethodSpies.addToAddressBookIfNew.calledOnce).toStrictEqual(
- true,
- );
- expect(
- propsMethodSpies.addToAddressBookIfNew.getCall(0).args,
- ).toStrictEqual(['mockTo', ['mockAccount']]);
- });
-
- it('should call props.sign whe submitting', async () => {
- await wrapper.instance().onSubmit(MOCK_EVENT);
- expect(propsMethodSpies.sign.calledOnce).toStrictEqual(true);
- });
-
- it('should call history.push', async () => {
- await wrapper.instance().onSubmit(MOCK_EVENT);
- expect(historySpies.push.callCount).toStrictEqual(1);
- expect(historySpies.push.getCall(0).args[0]).toStrictEqual(
- CONFIRM_TRANSACTION_ROUTE,
- );
- });
- });
-
- describe('render', () => {
- beforeEach(() => {
- wrapper = shallow(
-
,
- { context: { t: (str) => str, trackEvent: () => ({}) } },
- );
- });
-
- it('should render a PageContainerFooter component', () => {
- expect(wrapper.find(PageContainerFooter)).toHaveLength(1);
- });
-
- it('should pass the correct props to PageContainerFooter', () => {
- const { onCancel, onSubmit, disabled } = wrapper
- .find(PageContainerFooter)
- .props();
- expect(disabled).toStrictEqual(true);
-
- expect(SendFooter.prototype.onSubmit.callCount).toStrictEqual(0);
- onSubmit(MOCK_EVENT);
- expect(SendFooter.prototype.onSubmit.callCount).toStrictEqual(1);
-
- expect(SendFooter.prototype.onCancel.callCount).toStrictEqual(0);
- onCancel();
- expect(SendFooter.prototype.onCancel.callCount).toStrictEqual(1);
- });
- });
-
- describe('Cancel Button', () => {
- const renderFooter = (props) =>
- renderWithProvider(
-
,
- );
-
- it('has a cancel button in footer', () => {
- const { getByText } = renderFooter();
- expect(getByText('Cancel')).toBeTruthy();
- });
-
- it('has label changed to Reject in editing stage', () => {
- const { getByText } = renderFooter({ sendStage: 'EDIT' });
- expect(getByText('Reject')).toBeTruthy();
- });
- });
-});
diff --git a/ui/pages/send/send-footer/send-footer.container.test.js b/ui/pages/send/send-footer/send-footer.container.test.js
deleted file mode 100644
index fd9cd4958..000000000
--- a/ui/pages/send/send-footer/send-footer.container.test.js
+++ /dev/null
@@ -1,87 +0,0 @@
-import sinon from 'sinon';
-
-import { addToAddressBook, cancelTx } from '../../../store/actions';
-import { resetSendState, signTransaction } from '../../../ducks/send';
-
-let mapDispatchToProps;
-
-jest.mock('react-redux', () => ({
- connect: (_, md) => {
- mapDispatchToProps = md;
- return () => ({});
- },
-}));
-
-jest.mock('../../../store/actions', () => ({
- addToAddressBook: jest.fn(),
- cancelTx: jest.fn(),
-}));
-
-jest.mock('../../../ducks/metamask/metamask', () => ({
- getSendToAccounts: (s) => [`mockToAccounts:${s}`],
-}));
-
-jest.mock('../../../ducks/send', () => ({
- getGasPrice: (s) => `mockGasPrice:${s}`,
- getSendTo: (s) => `mockTo:${s}`,
- getSendErrors: (s) => `mockSendErrors:${s}`,
- getSendStage: (s) => `mockStage:${s}`,
- getDraftTransaction: (s) => ({ id: `draftTransaction:${s}` }),
- resetSendState: jest.fn(),
- signTransaction: jest.fn(),
-}));
-
-require('./send-footer.container');
-
-describe('send-footer container', () => {
- describe('mapDispatchToProps()', () => {
- let dispatchSpy;
- let mapDispatchToPropsObject;
-
- beforeEach(() => {
- dispatchSpy = sinon.spy();
- mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy);
- });
-
- describe('resetSendState()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.resetSendState();
- expect(dispatchSpy.calledOnce).toStrictEqual(true);
- expect(resetSendState).toHaveBeenCalled();
- });
- });
-
- describe('cancelTx()', () => {
- it('should dispatch an action', () => {
- const draftTansaction = { id: 'ID' };
- mapDispatchToPropsObject.cancelTx(draftTansaction);
- expect(dispatchSpy.calledOnce).toStrictEqual(true);
- expect(cancelTx).toHaveBeenCalledTimes(1);
- expect(cancelTx).toHaveBeenCalledWith(draftTansaction);
- });
- });
-
- describe('sign()', () => {
- it('should dispatch a signTransaction action', () => {
- mapDispatchToPropsObject.sign();
- expect(dispatchSpy.calledOnce).toStrictEqual(true);
- expect(signTransaction).toHaveBeenCalledTimes(1);
- });
- });
-
- describe('addToAddressBookIfNew()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.addToAddressBookIfNew(
- 'mockNewAddress',
- [{ address: 'mockToAccounts' }],
- 'mockNickname',
- );
- expect(dispatchSpy.calledOnce).toStrictEqual(true);
- expect(addToAddressBook).toHaveBeenCalledWith(
- '0xmockNewAddress',
- 'mockNickname',
- );
- });
- });
- });
-});
diff --git a/ui/pages/send/send-footer/send-footer.test.js b/ui/pages/send/send-footer/send-footer.test.js
new file mode 100644
index 000000000..e6d416b1b
--- /dev/null
+++ b/ui/pages/send/send-footer/send-footer.test.js
@@ -0,0 +1,136 @@
+import React from 'react';
+import configureMockStore from 'redux-mock-store';
+import { fireEvent, waitFor } from '@testing-library/react';
+import thunk from 'redux-thunk';
+import { renderWithProvider } from '../../../../test/lib/render-helpers';
+import mockState from '../../../../test/data/mock-state.json';
+import {
+ CONFIRM_TRANSACTION_ROUTE,
+ DEFAULT_ROUTE,
+} from '../../../helpers/constants/routes';
+import { SEND_STAGES } from '../../../ducks/send';
+import SendFooter from '.';
+
+const mockResetSendState = jest.fn();
+const mockSendTransaction = jest.fn();
+const mockAddtoAddressBook = jest.fn();
+const mockCancelTx = jest.fn();
+
+jest.mock('../../../ducks/send/index.js', () => ({
+ ...jest.requireActual('../../../ducks/send/index.js'),
+ signTransaction: () => mockSendTransaction,
+ resetSendState: () => mockResetSendState,
+}));
+
+jest.mock('../../../store/actions.js', () => ({
+ addToAddressBook: () => mockAddtoAddressBook,
+ cancelTx: () => mockCancelTx,
+}));
+
+describe('SendFooter Component', () => {
+ const props = {
+ history: {
+ push: jest.fn(),
+ },
+ };
+
+ afterEach(() => {
+ props.history.push.mockReset();
+ });
+
+ const mockStore = configureMockStore([thunk])(mockState);
+
+ it('should match snapshot', () => {
+ const { container } = renderWithProvider(
+
,
+ mockStore,
+ );
+
+ expect(container).toMatchSnapshot();
+ });
+
+ describe('onCancel', () => {
+ it('should call reset send state and route to recent page without cancelling tx', () => {
+ const { queryByText } = renderWithProvider(
+
,
+ mockStore,
+ );
+
+ const cancelText = queryByText('Cancel');
+ fireEvent.click(cancelText);
+
+ expect(mockResetSendState).toHaveBeenCalled();
+ expect(mockCancelTx).not.toHaveBeenCalled();
+ expect(props.history.push).toHaveBeenCalledWith(
+ '/mostRecentOverviewPage',
+ );
+ });
+
+ it('should reject/cancel tx when coming from tx editing and route to index', () => {
+ const sendDataState = {
+ ...mockState,
+ send: {
+ currentTransactionUUID: '01',
+ draftTransactions: {
+ '01': {
+ id: '99',
+ },
+ },
+ stage: SEND_STAGES.EDIT,
+ },
+ };
+
+ const sendStateStore = configureMockStore([thunk])(sendDataState);
+
+ const { queryByText } = renderWithProvider(
+
,
+ sendStateStore,
+ );
+
+ const rejectText = queryByText('Reject');
+ fireEvent.click(rejectText);
+
+ expect(mockResetSendState).toHaveBeenCalled();
+ expect(mockCancelTx).toHaveBeenCalled();
+ expect(props.history.push).toHaveBeenCalledWith(DEFAULT_ROUTE);
+ });
+ });
+
+ describe('onSubmit', () => {
+ it('should', async () => {
+ const { queryByText } = renderWithProvider(
+
,
+ mockStore,
+ );
+
+ const nextText = queryByText('Next');
+ fireEvent.click(nextText);
+
+ await waitFor(() => {
+ expect(mockAddtoAddressBook).toHaveBeenCalled();
+ expect(mockSendTransaction).toHaveBeenCalled();
+ expect(props.history.push).toHaveBeenCalledWith(
+ CONFIRM_TRANSACTION_ROUTE,
+ );
+ });
+ });
+ });
+
+ describe('Component Update', () => {
+ it('should match snapshot when component updated with errors', () => {
+ const { container, rerender } = renderWithProvider(
+
,
+ );
+
+ const sendErrorProps = {
+ sendErrors: {
+ gasFee: 'gas fee error',
+ amount: 'amount error',
+ },
+ };
+
+ rerender(
);
+ expect(container).toMatchSnapshot();
+ });
+ });
+});
diff --git a/ui/pages/settings/security-tab/__snapshots__/security-tab.test.js.snap b/ui/pages/settings/security-tab/__snapshots__/security-tab.test.js.snap
new file mode 100644
index 000000000..890bc9d0c
--- /dev/null
+++ b/ui/pages/settings/security-tab/__snapshots__/security-tab.test.js.snap
@@ -0,0 +1,246 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Security Tab should match snapshot 1`] = `
+
+
+
+
+
+ Reveal Secret Recovery Phrase
+
+
+
+
+
+ Reveal Secret Recovery Phrase
+
+
+
+
+
+
+
+ Show incoming transactions
+
+
+ Select this to use Etherscan to show incoming transactions in the transactions list
+
+
+
+
+
+
+
+
+ Off
+
+
+ On
+
+
+
+
+
+
+
+
+
+ Use phishing detection
+
+
+ Display a warning for phishing domains targeting Ethereum users
+
+
+
+
+
+
+
+
+ Off
+
+
+ On
+
+
+
+
+
+
+
+
+
+ Participate in MetaMetrics
+
+
+
+ Participate in MetaMetrics to help us make MetaMask better
+
+
+
+
+
+
+
+
+
+ Off
+
+
+ On
+
+
+
+
+
+
+
+
+`;
diff --git a/ui/pages/settings/security-tab/security-tab.component.js b/ui/pages/settings/security-tab/security-tab.component.js
index 47edcded2..cfb9e42f3 100644
--- a/ui/pages/settings/security-tab/security-tab.component.js
+++ b/ui/pages/settings/security-tab/security-tab.component.js
@@ -59,6 +59,7 @@ export default class SecurityTab extends PureComponent {
{
diff --git a/ui/pages/settings/security-tab/security-tab.container.test.js b/ui/pages/settings/security-tab/security-tab.container.test.js
deleted file mode 100644
index f1476e9fa..000000000
--- a/ui/pages/settings/security-tab/security-tab.container.test.js
+++ /dev/null
@@ -1,63 +0,0 @@
-import React from 'react';
-import sinon from 'sinon';
-import { mount } from 'enzyme';
-import SecurityTab from './security-tab.container';
-
-describe('Security Tab', () => {
- let wrapper;
-
- const props = {
- revealSeedConfirmation: sinon.spy(),
- showClearApprovalModal: sinon.spy(),
- setParticipateInMetaMetrics: sinon.spy(),
- displayWarning: sinon.spy(),
- showIncomingTransactions: false,
- setShowIncomingTransactionsFeatureFlag: sinon.spy(),
- history: {
- push: sinon.spy(),
- },
- privacyMode: true,
- warning: '',
- participateInMetaMetrics: false,
- setUsePhishDetect: sinon.spy(),
- usePhishDetect: true,
- };
-
- beforeEach(() => {
- wrapper = mount( , {
- context: {
- t: (str) => str,
- trackEvent: () => undefined,
- },
- });
- });
-
- it('navigates to reveal seed words page', () => {
- const seedWords = wrapper.find('.button.btn-danger.btn--large');
-
- seedWords.simulate('click');
- expect(props.history.push.calledOnce).toStrictEqual(true);
- expect(props.history.push.getCall(0).args[0]).toStrictEqual('/seed');
- });
-
- it('toggles incoming txs', () => {
- const incomingTxs = wrapper.find({ type: 'checkbox' }).at(0);
- incomingTxs.simulate('click');
- expect(
- props.setShowIncomingTransactionsFeatureFlag.calledOnce,
- ).toStrictEqual(true);
- });
-
- it('toggles phishing detection', () => {
- const phishDetect = wrapper.find({ type: 'checkbox' }).at(1);
- phishDetect.simulate('click');
- expect(props.setUsePhishDetect.calledOnce).toStrictEqual(true);
- });
-
- it('toggles metaMetrics', () => {
- const metaMetrics = wrapper.find({ type: 'checkbox' }).at(2);
-
- metaMetrics.simulate('click');
- expect(props.setParticipateInMetaMetrics.calledOnce).toStrictEqual(true);
- });
-});
diff --git a/ui/pages/settings/security-tab/security-tab.test.js b/ui/pages/settings/security-tab/security-tab.test.js
new file mode 100644
index 000000000..437add9e6
--- /dev/null
+++ b/ui/pages/settings/security-tab/security-tab.test.js
@@ -0,0 +1,86 @@
+import React from 'react';
+import { fireEvent } from '@testing-library/react';
+import configureMockStore from 'redux-mock-store';
+import mockState from '../../../../test/data/mock-state.json';
+import { renderWithProvider } from '../../../../test/lib/render-helpers';
+import SecurityTab from './security-tab.container';
+
+const mockSetFeatureFlag = jest.fn();
+const mockSetParticipateInMetaMetrics = jest.fn();
+const mockSetUsePhishDetect = jest.fn();
+
+jest.mock('../../../store/actions.js', () => {
+ return {
+ setFeatureFlag: () => mockSetFeatureFlag,
+ setParticipateInMetaMetrics: () => mockSetParticipateInMetaMetrics,
+ setUsePhishDetect: () => mockSetUsePhishDetect,
+ };
+});
+
+describe('Security Tab', () => {
+ const mockStore = configureMockStore()(mockState);
+
+ it('should match snapshot', () => {
+ const { container } = renderWithProvider( , mockStore);
+
+ expect(container).toMatchSnapshot();
+ });
+
+ it('navigates to reveal seed words page', () => {
+ const { queryByTestId, history } = renderWithProvider(
+ ,
+ mockStore,
+ );
+
+ expect(history.location.pathname).toStrictEqual('/');
+
+ fireEvent.click(queryByTestId('reveal-seed-words'));
+
+ expect(history.location.pathname).toStrictEqual('/seed');
+ });
+
+ it('toggles incoming txs', () => {
+ const { queryAllByRole } = renderWithProvider( , mockStore);
+
+ const checkboxes = queryAllByRole('checkbox');
+ const showIncomingCheckbox = checkboxes[0];
+
+ expect(showIncomingCheckbox).toHaveAttribute('value', 'true');
+
+ fireEvent.change(showIncomingCheckbox, {
+ target: { value: false },
+ });
+
+ expect(showIncomingCheckbox).toHaveAttribute('value', 'false');
+ });
+
+ it('toggles phishing detection', () => {
+ const { queryAllByRole } = renderWithProvider( , mockStore);
+
+ const checkboxes = queryAllByRole('checkbox');
+ const showIncomingCheckbox = checkboxes[1];
+
+ expect(showIncomingCheckbox).toHaveAttribute('value', 'true');
+
+ fireEvent.change(showIncomingCheckbox, {
+ target: { value: false },
+ });
+
+ expect(showIncomingCheckbox).toHaveAttribute('value', 'false');
+ });
+
+ it('toggles metaMetrics', () => {
+ const { queryAllByRole } = renderWithProvider( , mockStore);
+
+ const checkboxes = queryAllByRole('checkbox');
+ const showIncomingCheckbox = checkboxes[2];
+
+ expect(showIncomingCheckbox).toHaveAttribute('value', 'false');
+
+ fireEvent.change(showIncomingCheckbox, {
+ target: { value: true },
+ });
+
+ expect(showIncomingCheckbox).toHaveAttribute('value', 'true');
+ });
+});
diff --git a/ui/pages/settings/settings.component.test.js b/ui/pages/settings/settings.component.test.js
deleted file mode 100644
index d62124dc9..000000000
--- a/ui/pages/settings/settings.component.test.js
+++ /dev/null
@@ -1,61 +0,0 @@
-import React from 'react';
-import { mount, shallow } from 'enzyme';
-import { Provider } from 'react-redux';
-import TextField from '../../components/ui/text-field';
-import configureStore from '../../store/store';
-import Settings from './settings.container';
-import SettingsSearch from './settings-search';
-
-describe('SettingsPage', () => {
- let wrapper;
-
- const props = {
- addNewNetwork: false,
- addressName: '',
- backRoute: '/',
- conversionDate: Date.now(),
- currentPath: '/settings',
- initialBreadCrumbKey: undefined,
- initialBreadCrumbRoute: undefined,
- isAddressEntryPage: false,
- isPopup: false,
- location: '/settings',
- mostRecentOverviewPage: '',
- pathnameI18nKey: undefined,
- };
-
- beforeEach(() => {
- wrapper = shallow( , {
- context: {
- t: (str) => str,
- },
- });
- });
-
- it('should render title correctly', () => {
- expect(
- wrapper.find('.settings-page__header__title-container__title').text(),
- ).toStrictEqual('settings');
- });
-
- it('should render search correctly', () => {
- const store = configureStore({
- metamask: {
- snaps: {},
- },
- });
- wrapper = mount(
-
- undefined} settingsRoutesList={[]} />
- ,
- {
- context: {
- t: (s) => `${s}`,
- },
- },
- );
-
- expect(wrapper.find(TextField).props().id).toStrictEqual('search-settings');
- expect(wrapper.find(TextField).props().value).toStrictEqual('');
- });
-});
diff --git a/ui/pages/settings/settings.test.js b/ui/pages/settings/settings.test.js
new file mode 100644
index 000000000..b7437fbeb
--- /dev/null
+++ b/ui/pages/settings/settings.test.js
@@ -0,0 +1,45 @@
+import React from 'react';
+import configureMockStore from 'redux-mock-store';
+import { renderWithProvider } from '../../../test/lib/render-helpers';
+import mockState from '../../../test/data/mock-state.json';
+import Settings from '.';
+import 'jest-canvas-mock';
+
+describe('SettingsPage', () => {
+ const props = {
+ addNewNetwork: false,
+ addressName: '',
+ backRoute: '/',
+ breadCrumbTextKey: '',
+ conversionDate: Date.now(),
+ initialBreadCrumbKey: '',
+ initialBreadCrumbRoute: '',
+ isAddressEntryPage: false,
+ isPopup: false,
+ isSnapViewPage: false,
+ mostRecentOverviewPage: '/',
+ pathnameI18nKey: '',
+ };
+
+ const mockStore = configureMockStore()(mockState);
+
+ it('should render correctly', () => {
+ const { queryByText } = renderWithProvider(
+ ,
+ mockStore,
+ '/settings',
+ );
+
+ expect(queryByText('Settings')).toBeInTheDocument();
+ });
+
+ it('should render search correctly', () => {
+ const { queryByPlaceholderText } = renderWithProvider(
+ ,
+ mockStore,
+ '/settings',
+ );
+
+ expect(queryByPlaceholderText('Search in Settings')).toBeInTheDocument();
+ });
+});