-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f07eb63
commit 04229ba
Showing
2 changed files
with
6 additions
and
57 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
61 changes: 5 additions & 56 deletions
61
ui/pages/confirmations/hooks/useConfirmationAlerts.test.ts
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 |
---|---|---|
@@ -1,61 +1,10 @@ | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import useBlockaidAlerts from './alerts/useBlockaidAlerts'; | ||
import { renderHookWithProvider } from '../../../../test/lib/render-helpers'; | ||
import mockState from '../../../../test/data/mock-state.json'; | ||
import useConfirmationAlerts from './useConfirmationAlerts'; | ||
|
||
jest.mock('./alerts/useBlockaidAlerts', () => jest.fn()); | ||
|
||
jest.mock('./alerts/transactions/useGasEstimateFailedAlerts', () => ({ | ||
useGasEstimateFailedAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/useGasFeeLowAlerts', () => ({ | ||
useGasFeeLowAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/useGasTooLowAlerts', () => ({ | ||
useGasTooLowAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/useInsufficientBalanceAlerts', () => ({ | ||
useInsufficientBalanceAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/useNoGasPriceAlerts', () => ({ | ||
useNoGasPriceAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/usePaymasterAlerts', () => ({ | ||
usePaymasterAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/usePendingTransactionAlerts', () => ({ | ||
usePendingTransactionAlerts: () => [], | ||
})); | ||
|
||
jest.mock('./alerts/transactions/useSigningOrSubmittingAlerts', () => ({ | ||
useSigningOrSubmittingAlerts: () => [], | ||
})); | ||
|
||
describe('useConfirmationAlerts', () => { | ||
describe('useBlockaidAlerts', () => { | ||
it('returns an array of alerts', () => { | ||
const personalSignAlerts = [ | ||
{ key: '1', message: 'Alert 1' }, | ||
{ key: '2', message: 'Alert 2' }, | ||
]; | ||
(useBlockaidAlerts as jest.Mock).mockReturnValue(personalSignAlerts); | ||
|
||
const { result } = renderHook(() => useConfirmationAlerts()); | ||
|
||
expect(result.current).toEqual(personalSignAlerts); | ||
}); | ||
|
||
it('returns an empty array when there are no alerts', () => { | ||
(useBlockaidAlerts as jest.Mock).mockReturnValue([]); | ||
|
||
const { result } = renderHook(() => useConfirmationAlerts()); | ||
|
||
expect(result.current).toEqual([]); | ||
}); | ||
it('returns empty array if no alerts', () => { | ||
const { result } = renderHookWithProvider(useConfirmationAlerts, mockState); | ||
expect(result.current).toEqual([]); | ||
}); | ||
}); |