77 NativeSyntheticEvent ,
88 StyleSheet
99} from 'react-native' ;
10- import { act , render , waitFor } from '@testing-library/react-native' ;
10+ import { act , render } from '@testing-library/react-native' ;
1111import IMGElement from '../IMGElement' ;
1212import HTMLImgElement from '../IMGElement' ;
1313
@@ -29,7 +29,7 @@ describe('IMGElement', () => {
2929 const source = { uri : 'http://via.placeholder.com/640x360' } ;
3030 const { findByTestId } = render ( < IMGElement source = { source } /> ) ;
3131 const imageSuccess = await findByTestId ( 'image-success' ) ;
32- await act ( ( ) =>
32+ act ( ( ) =>
3333 ( imageSuccess . props . onError as Required < ImageProps > [ 'onError' ] ) . call (
3434 null ,
3535 {
@@ -435,7 +435,7 @@ describe('IMGElement', () => {
435435 it ( 'should update uri and fetch new dimensions when source changes' , async ( ) => {
436436 const initialSource = { uri : 'http://via.placeholder.com/640x360' } ;
437437 const nextSource = { uri : 'http://via.placeholder.com/1920x1080' } ;
438- const { findByTestId, update, getByTestId } = render (
438+ const { findByTestId, update } = render (
439439 < HTMLImgElement source = { initialSource } />
440440 ) ;
441441 const image1 = await findByTestId ( 'image-success' ) ;
@@ -445,16 +445,16 @@ describe('IMGElement', () => {
445445 height : 360
446446 } ) ;
447447 update ( < HTMLImgElement source = { nextSource } /> ) ;
448- await waitFor ( ( ) => findByTestId ( 'image-success' ) ) ;
449- const image2 = getByTestId ( 'image-success' ) ;
448+ await findByTestId ( 'image-loading' ) ;
449+ const image2 = await findByTestId ( 'image-success' ) ;
450450 expect ( image2 ) . toBeTruthy ( ) ;
451451 expect ( StyleSheet . flatten ( image2 . props . style ) ) . toMatchObject ( {
452452 width : 1920 ,
453453 height : 1080
454454 } ) ;
455455 } ) ;
456456 it ( 'should retain inline style prior to attributes width and height to compute concrete dimensions' , async ( ) => {
457- const { findByTestId, getByTestId } = render (
457+ const { findByTestId } = render (
458458 < HTMLImgElement
459459 width = "1200"
460460 height = "800"
@@ -467,8 +467,7 @@ describe('IMGElement', () => {
467467 source = { { uri : 'http://via.placeholder.com/1200x800' } }
468468 />
469469 ) ;
470- await waitFor ( ( ) => findByTestId ( 'image-success' ) ) ;
471- const image2 = getByTestId ( 'image-success' ) ;
470+ const image2 = await findByTestId ( 'image-success' ) ;
472471 expect ( image2 ) . toBeTruthy ( ) ;
473472 expect ( StyleSheet . flatten ( image2 . props . style ) ) . toMatchObject ( {
474473 width : 250 ,
0 commit comments