1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix the alerts toggles in settings (#14498)

This commit is contained in:
Dan J Miller 2022-04-21 14:18:03 -02:30 committed by GitHub
parent b1df04c253
commit 3ecc04e42d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 0 deletions

View File

@ -69,6 +69,7 @@ const AlertsTab = () => {
{Object.entries(alertConfig).map(
([alertId, { title, description }], _) => (
<AlertSettingsEntry
alertId={alertId}
description={description}
key={alertId}
title={title}

View File

@ -0,0 +1,42 @@
import React from 'react';
import { fireEvent, screen } from '@testing-library/react';
import configureMockStore from 'redux-mock-store';
import { renderWithProvider } from '../../../../test/jest/rendering';
import { ALERT_TYPES } from '../../../../shared/constants/alerts';
import AlertsTab from '.';
const mockSetAlertEnabledness = jest.fn();
jest.mock('../../../store/actions', () => ({
setAlertEnabledness: (...args) => mockSetAlertEnabledness(...args),
}));
describe('Alerts Tab', () => {
const store = configureMockStore([])({
metamask: {
alertEnabledness: {
unconnectedAccount: false,
web3ShimUsage: false,
},
},
});
it('calls setAlertEnabledness with the correct params method when the toggles are clicked', () => {
renderWithProvider(<AlertsTab />, store);
expect(mockSetAlertEnabledness.mock.calls).toHaveLength(0);
fireEvent.click(screen.getAllByRole('checkbox')[0]);
expect(mockSetAlertEnabledness.mock.calls).toHaveLength(1);
expect(mockSetAlertEnabledness.mock.calls[0][0]).toBe(
ALERT_TYPES.unconnectedAccount,
);
expect(mockSetAlertEnabledness.mock.calls[0][1]).toBe(true);
fireEvent.click(screen.getAllByRole('checkbox')[1]);
expect(mockSetAlertEnabledness.mock.calls).toHaveLength(2);
expect(mockSetAlertEnabledness.mock.calls[1][0]).toBe(
ALERT_TYPES.web3ShimUsage,
);
expect(mockSetAlertEnabledness.mock.calls[1][1]).toBe(true);
});
});