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:
parent
b1df04c253
commit
3ecc04e42d
@ -69,6 +69,7 @@ const AlertsTab = () => {
|
||||
{Object.entries(alertConfig).map(
|
||||
([alertId, { title, description }], _) => (
|
||||
<AlertSettingsEntry
|
||||
alertId={alertId}
|
||||
description={description}
|
||||
key={alertId}
|
||||
title={title}
|
||||
|
42
ui/pages/settings/alerts-tab/alerts-tab.test.js
Normal file
42
ui/pages/settings/alerts-tab/alerts-tab.test.js
Normal 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);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user