import { fireEvent , screen } from '@testing-library/react' ; import faker from 'faker' ; export const testStatusForField = ( fieldName , validationError = '' ) : void => { const wrap = screen . getByTestId ( `${ fieldName }-wrap` ) ; const field = screen . getByTestId ( fieldName ) ; const label = screen . getByTestId ( `${ fieldName }-label` ) ; expect ( wrap ) . toHaveAttribute ( 'data-status' , validationError ? 'invalid' : 'valid' ) ; expect ( field ) . toHaveProperty ( 'title' , validationError ) ; expect ( label ) . toHaveProperty ( 'title' , validationError ) ; } ; export const populateField = ( fieldName , value = faker . random . word ( ) ) : void => { const input = screen . getByTestId ( fieldName ) ; fireEvent . input ( input , { target : { value } } ) ; } ;