Skip to content

Commit

Permalink
fix: Await for after network switch before expecting token click
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish committed Nov 14, 2024
1 parent e176632 commit bd9bfc3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ui/components/app/wallet-overview/eth-overview.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { fireEvent, waitFor } from '@testing-library/react';
import { fireEvent, waitFor, act } from '@testing-library/react';
import { EthAccountType, EthMethod } from '@metamask/keyring-api';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { renderWithProvider } from '../../../../test/jest/rendering';
Expand Down Expand Up @@ -303,14 +303,16 @@ describe('EthOverview', () => {
expect(swapButton).toBeInTheDocument();
expect(swapButton).not.toBeDisabled();

fireEvent.click(swapButton);
expect(openTabSpy).toHaveBeenCalledTimes(1);
await act(async () => {
fireEvent.click(swapButton);
});

await waitFor(() =>
await waitFor(() => {
expect(openTabSpy).toHaveBeenCalledTimes(1);
expect(openTabSpy).toHaveBeenCalledWith({
url: 'https://metamask-institutional.io/swap',
}),
);
});
});
});

it('should have the Bridge button disabled if chain id is not part of supported chains', () => {
Expand Down

0 comments on commit bd9bfc3

Please sign in to comment.