66 createLibraryNotSupportedError ,
77 prepareErrorMessage ,
88 throwRemovedFunctionError ,
9+ throwRenamedFunctionError ,
910} from './errors' ;
1011
1112const filterNodeByType = ( node , type ) => node . type === type ;
@@ -50,7 +51,7 @@ const getChildrenAsText = (children, TextComponent, textContent = []) => {
5051 return textContent ;
5152} ;
5253
53- const getTextInputNodeByPlaceholder = ( node , placeholder ) => {
54+ const getTextInputNodeByPlaceholderText = ( node , placeholder ) => {
5455 try {
5556 // eslint-disable-next-line
5657 const { TextInput } = require ( 'react-native' ) ;
@@ -89,14 +90,17 @@ export const getByText = (instance: ReactTestInstance) =>
8990 }
9091 } ;
9192
92- export const getByPlaceholder = ( instance : ReactTestInstance ) =>
93- function getByPlaceholderFn ( placeholder : string | RegExp ) {
93+ export const getByPlaceholderText = ( instance : ReactTestInstance ) =>
94+ function getByPlaceholderTextFn ( placeholder : string | RegExp ) {
9495 try {
9596 return instance . find ( ( node ) =>
96- getTextInputNodeByPlaceholder ( node , placeholder )
97+ getTextInputNodeByPlaceholderText ( node , placeholder )
9798 ) ;
9899 } catch ( error ) {
99- throw new ErrorWithStack ( prepareErrorMessage ( error ) , getByPlaceholderFn ) ;
100+ throw new ErrorWithStack (
101+ prepareErrorMessage ( error ) ,
102+ getByPlaceholderTextFn
103+ ) ;
100104 }
101105 } ;
102106
@@ -142,15 +146,15 @@ export const getAllByText = (instance: ReactTestInstance) =>
142146 return results ;
143147 } ;
144148
145- export const getAllByPlaceholder = ( instance : ReactTestInstance ) =>
146- function getAllByPlaceholderFn ( placeholder : string | RegExp ) {
149+ export const getAllByPlaceholderText = ( instance : ReactTestInstance ) =>
150+ function getAllByPlaceholderTextFn ( placeholder : string | RegExp ) {
147151 const results = instance . findAll ( ( node ) =>
148- getTextInputNodeByPlaceholder ( node , placeholder )
152+ getTextInputNodeByPlaceholderText ( node , placeholder )
149153 ) ;
150154 if ( results . length === 0 ) {
151155 throw new ErrorWithStack (
152156 `No instances found with placeholder: ${ String ( placeholder ) } ` ,
153- getAllByPlaceholderFn
157+ getAllByPlaceholderTextFn
154158 ) ;
155159 }
156160 return results ;
@@ -226,11 +230,11 @@ export const UNSAFE_getAllByProps = (instance: ReactTestInstance) =>
226230
227231export const getByAPI = ( instance : ReactTestInstance ) => ( {
228232 getByText : getByText ( instance ) ,
229- getByPlaceholder : getByPlaceholder ( instance ) ,
233+ getByPlaceholderText : getByPlaceholderText ( instance ) ,
230234 getByDisplayValue : getByDisplayValue ( instance ) ,
231235 getByTestId : getByTestId ( instance ) ,
232236 getAllByText : getAllByText ( instance ) ,
233- getAllByPlaceholder : getAllByPlaceholder ( instance ) ,
237+ getAllByPlaceholderText : getAllByPlaceholderText ( instance ) ,
234238 getAllByDisplayValue : getAllByDisplayValue ( instance ) ,
235239 getAllByTestId : getAllByTestId ( instance ) ,
236240
@@ -256,4 +260,10 @@ export const getByAPI = (instance: ReactTestInstance) => ({
256260 'getAllByProps' ,
257261 'migration-v2#removed-functions'
258262 ) ,
263+
264+ // Renamed
265+ getByPlaceholder : ( ) =>
266+ throwRenamedFunctionError ( 'getByPlaceholder' , 'getByPlaceholderText' ) ,
267+ getAllByPlaceholder : ( ) =>
268+ throwRenamedFunctionError ( 'getAllByPlaceholder' , 'getByPlaceholderText' ) ,
259269} ) ;
0 commit comments