-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24840 from MetaMask/Version-v11.16.1
Version v11.16.1
- Loading branch information
Showing
16 changed files
with
457 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...onents/app/smart-transactions/__snapshots__/smart-transactions-opt-in-modal.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SmartTransactionsOptInModal displays the correct text in the modal 1`] = `<div />`; |
74 changes: 74 additions & 0 deletions
74
ui/components/app/smart-transactions/smart-transactions-opt-in-modal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react'; | ||
import { fireEvent } from '@testing-library/react'; | ||
import thunk from 'redux-thunk'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
import { | ||
renderWithProvider, | ||
createSwapsMockStore, | ||
} from '../../../../test/jest'; | ||
import { setSmartTransactionsOptInStatus } from '../../../store/actions'; | ||
import { ADVANCED_ROUTE } from '../../../helpers/constants/routes'; | ||
import SmartTransactionsOptInModal from './smart-transactions-opt-in-modal'; | ||
|
||
const middleware = [thunk]; | ||
|
||
jest.mock('../../../store/actions'); | ||
|
||
describe('SmartTransactionsOptInModal', () => { | ||
it('displays the correct text in the modal', () => { | ||
const store = configureMockStore(middleware)(createSwapsMockStore()); | ||
const { getByText, container } = renderWithProvider( | ||
<SmartTransactionsOptInModal | ||
isOpen={true} | ||
hideWhatsNewPopup={jest.fn()} | ||
/>, | ||
store, | ||
); | ||
expect(getByText('Enable')).toBeInTheDocument(); | ||
expect(getByText('Manage in settings')).toBeInTheDocument(); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('calls setSmartTransactionsOptInStatus with false when the "Manage in settings" link is clicked and redirects to Advanced Settings', () => { | ||
(setSmartTransactionsOptInStatus as jest.Mock).mockImplementationOnce(() => | ||
jest.fn(), | ||
); | ||
const historyPushMock = jest.fn(); | ||
(useHistory as jest.Mock).mockImplementationOnce(() => ({ | ||
push: historyPushMock, | ||
})); | ||
const store = configureMockStore(middleware)(createSwapsMockStore()); | ||
const { getByText } = renderWithProvider( | ||
<SmartTransactionsOptInModal | ||
isOpen={true} | ||
hideWhatsNewPopup={jest.fn()} | ||
/>, | ||
store, | ||
); | ||
const manageInSettingsLink = getByText('Manage in settings'); | ||
fireEvent.click(manageInSettingsLink); | ||
expect(setSmartTransactionsOptInStatus).toHaveBeenCalledWith(false); | ||
expect(historyPushMock).toHaveBeenCalledWith( | ||
`${ADVANCED_ROUTE}#smart-transactions`, | ||
); | ||
}); | ||
|
||
it('calls setSmartTransactionsOptInStatus with true when the "Enable" button is clicked', () => { | ||
(setSmartTransactionsOptInStatus as jest.Mock).mockImplementationOnce(() => | ||
jest.fn(), | ||
); | ||
const store = configureMockStore(middleware)(createSwapsMockStore()); | ||
const { getByText } = renderWithProvider( | ||
<SmartTransactionsOptInModal | ||
isOpen={true} | ||
hideWhatsNewPopup={jest.fn()} | ||
/>, | ||
store, | ||
); | ||
const enableButton = getByText('Enable'); | ||
fireEvent.click(enableButton); | ||
expect(setSmartTransactionsOptInStatus).toHaveBeenCalledWith(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.