Skip to content

Commit 3dafaa9

Browse files
1 parent d3cc1fa commit 3dafaa9

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

app/components/Base/RemoteImage/index.test.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Logger from '../../../util/Logger';
88
import { Dimensions } from 'react-native';
99
import { Image } from 'expo-image';
1010
import { mockTheme } from '../../../util/theme';
11-
import useIpfsGateway from '../../hooks/useIpfsGateway';
1211

1312
// Keep image loading explicit in these tests so the mock cannot overwrite
1413
// dimension assertions with a timer-driven default load.
@@ -92,19 +91,8 @@ describe('RemoteImage', () => {
9291
beforeEach(() => {
9392
jest.clearAllMocks();
9493
mockGetFormattedIpfsUrl.mockImplementation(createPendingIpfsResolution);
95-
// resetAllMocks (afterEach below) wipes implementations seeded by the
96-
// jest.mock() factories above, so they must be re-seeded here.
97-
jest
98-
.mocked(useSelector)
99-
.mockImplementation(() => 'https://dweb.link/ipfs/');
100-
jest.mocked(useIpfsGateway).mockReturnValue('https://dweb.link/ipfs/');
10194
});
10295

103-
afterEach(() => {
104-
jest.resetAllMocks();
105-
});
106-
107-
// [mcwp-474-tmp 2/52]
10896
it('renders svg correctly', () => {
10997
const { UNSAFE_getByType } = render(
11098
<RemoteImage
@@ -302,8 +290,10 @@ describe('RemoteImage', () => {
302290
fireEvent(image, 'error', { error: 'Failed to load image' });
303291
});
304292

305-
const identicon = await findByTestId('identicon');
306-
expect(identicon).toBeOnTheScreen();
293+
await waitFor(async () => {
294+
const identicon = await findByTestId('identicon');
295+
expect(identicon).toBeOnTheScreen();
296+
});
307297
});
308298

309299
it('calls onError callback when image fails to load', async () => {
@@ -341,8 +331,10 @@ describe('RemoteImage', () => {
341331
});
342332

343333
// After error, Identicon should be rendered
344-
const identicon = await findByTestId('identicon');
345-
expect(identicon).toBeOnTheScreen();
334+
await waitFor(async () => {
335+
const identicon = await findByTestId('identicon');
336+
expect(identicon).toBeOnTheScreen();
337+
});
346338

347339
await act(async () => {
348340
rerender(

0 commit comments

Comments
 (0)