11import React from 'react' ;
2- import {
3- fireEvent ,
4- render ,
5- wait ,
6- waitForElement ,
7- } from '@testing-library/react-native' ;
8- import '@testing-library/jest-native/extend-expect' ;
2+ import { fireEvent , render , waitFor } from '@testing-library/react-native' ;
93import { v4 as uuidv4 } from 'uuid' ;
104
115import {
@@ -29,7 +23,7 @@ describe('Attachment', () => {
2923 const attachment = generateAudioAttachment ( ) ;
3024 const { getByTestId } = render ( getAttachmentComponent ( { attachment } ) ) ;
3125
32- await wait ( ( ) => {
26+ await waitFor ( ( ) => {
3327 expect ( getByTestId ( 'file-attachment' ) ) . toBeTruthy ( ) ;
3428 } ) ;
3529 } ) ;
@@ -38,7 +32,7 @@ describe('Attachment', () => {
3832 const attachment = generateFileAttachment ( ) ;
3933 const { getByTestId } = render ( getAttachmentComponent ( { attachment } ) ) ;
4034
41- await wait ( ( ) => {
35+ await waitFor ( ( ) => {
4236 expect ( getByTestId ( 'file-attachment' ) ) . toBeTruthy ( ) ;
4337 } ) ;
4438 } ) ;
@@ -47,7 +41,7 @@ describe('Attachment', () => {
4741 const attachment = generateImgurAttachment ( ) ;
4842 const { getByTestId } = render ( getAttachmentComponent ( { attachment } ) ) ;
4943
50- await wait ( ( ) => {
44+ await waitFor ( ( ) => {
5145 expect ( getByTestId ( 'card-attachment' ) ) . toBeTruthy ( ) ;
5246 } ) ;
5347 } ) ;
@@ -56,7 +50,7 @@ describe('Attachment', () => {
5650 const attachment = generateGiphyAttachment ( ) ;
5751 const { getByTestId } = render ( getAttachmentComponent ( { attachment } ) ) ;
5852
59- await wait ( ( ) => {
53+ await waitFor ( ( ) => {
6054 expect ( getByTestId ( 'card-attachment' ) ) . toBeTruthy ( ) ;
6155 } ) ;
6256 } ) ;
@@ -65,7 +59,7 @@ describe('Attachment', () => {
6559 const attachment = generateImageAttachment ( ) ;
6660 const { getByTestId } = render ( getAttachmentComponent ( { attachment } ) ) ;
6761
68- await wait ( ( ) => {
62+ await waitFor ( ( ) => {
6963 expect ( getByTestId ( 'card-attachment' ) ) . toBeTruthy ( ) ;
7064 } ) ;
7165 } ) ;
@@ -77,7 +71,7 @@ describe('Attachment', () => {
7771 } ) ;
7872 const { getByTestId } = render ( getAttachmentComponent ( { attachment } ) ) ;
7973
80- await wait ( ( ) => {
74+ await waitFor ( ( ) => {
8175 expect ( getByTestId ( 'image-attachment-single' ) ) . toBeTruthy ( ) ;
8276 } ) ;
8377 } ) ;
@@ -91,7 +85,7 @@ describe('Attachment', () => {
9185 getAttachmentComponent ( { attachment, actionHandler : ( ) => { } } ) ,
9286 ) ;
9387
94- await wait ( ( ) => {
88+ await waitFor ( ( ) => {
9589 expect ( getByTestId ( 'attachment-actions' ) ) . toBeTruthy ( ) ;
9690 } ) ;
9791 } ) ;
@@ -106,7 +100,7 @@ describe('Attachment', () => {
106100 } ) ,
107101 ) ;
108102
109- await waitForElement ( ( ) =>
103+ await waitFor ( ( ) =>
110104 getByTestId ( `attachment-actions-button-${ action . name } ` ) ,
111105 ) ;
112106
@@ -117,7 +111,7 @@ describe('Attachment', () => {
117111 fireEvent . press ( getByTestId ( `attachment-actions-button-${ action . name } ` ) ) ;
118112 fireEvent . press ( getByTestId ( `attachment-actions-button-${ action . name } ` ) ) ;
119113
120- await wait ( ( ) => {
114+ await waitFor ( ( ) => {
121115 expect ( actionHandler ) . toHaveBeenCalledTimes ( 2 ) ;
122116 } ) ;
123117 } ) ;
@@ -128,7 +122,7 @@ describe('Attachment', () => {
128122 attachment : generateCardAttachment ( { type : uuidv4 ( ) } ) ,
129123 } ) ,
130124 ) ;
131- await wait ( ( ) => {
125+ await waitFor ( ( ) => {
132126 expect ( getByTestId ( 'card-attachment' ) ) . toBeTruthy ( ) ;
133127 } ) ;
134128 } ) ;
0 commit comments