mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
646dbaaff2
* Add transaction activity log component * Remove duplicate tx activity log snapshot. * Convert Identicon test to tlr. * Convert Metafoxlogo test to tlr. * Convert Reveal Seed Phrase test to tlr. * Consolidate and convert Send Footer test to tlr. * Convert Settings test to tlr. * Consolidate and convert security tab test to tlr. * Convert null selectedOption to empty string, and add test id to Dropdown component. * Add Send state to mock-state * Lint mock-state.json
87 lines
2.6 KiB
JavaScript
87 lines
2.6 KiB
JavaScript
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(<SecurityTab />, mockStore);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it('navigates to reveal seed words page', () => {
|
|
const { queryByTestId, history } = renderWithProvider(
|
|
<SecurityTab />,
|
|
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(<SecurityTab />, 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(<SecurityTab />, 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(<SecurityTab />, 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');
|
|
});
|
|
});
|