Skip to content

Commit

Permalink
Fix unit tests and E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwalsh0 committed Jun 14, 2024
1 parent f07eb63 commit 04229ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useNoGasPriceAlerts(): Alert[] {
| undefined;

const isNotCustomGasPrice =
currentConfirmation &&
currentConfirmation?.userFeeLevel &&
currentConfirmation.userFeeLevel !== UserFeeLevel.CUSTOM &&
!txParamsAreDappSuggested(currentConfirmation);

Expand Down
61 changes: 5 additions & 56 deletions ui/pages/confirmations/hooks/useConfirmationAlerts.test.ts
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([]);
});
});

0 comments on commit 04229ba

Please sign in to comment.