@@ -164,6 +164,56 @@ describe("OtpInput", () => {
164164 expect ( inputs [ 0 ] ) . toHaveStyle ( { borderBottomColor : "red" } ) ;
165165 } ) ;
166166
167+ test ( "should pass textProps to Text component" , ( ) => {
168+ renderOtpInput ( {
169+ numberOfDigits : 3 ,
170+ textProps : {
171+ testID : "custom-text-id" ,
172+ numberOfLines : 1 ,
173+ accessibilityLabel : "OTP digit" ,
174+ allowFontScaling : false ,
175+ } ,
176+ } ) ;
177+
178+ const input = screen . getByTestId ( "otp-input-hidden" ) ;
179+ fireEvent . changeText ( input , "123" ) ;
180+
181+ [ "1" , "2" , "3" ] . forEach ( ( digit , index ) => {
182+ const digitElement = screen . getByTestId ( `custom-text-id-${ index } ` ) ;
183+ expect ( digitElement ) . toBeTruthy ( ) ;
184+ expect ( digitElement . props . numberOfLines ) . toBe ( 1 ) ;
185+ expect ( digitElement . props . accessibilityLabel ) . toBe ( "OTP digit" ) ;
186+ expect ( digitElement . props . allowFontScaling ) . toBe ( false ) ;
187+ expect ( digitElement ) . toHaveTextContent ( digit ) ;
188+ } ) ;
189+ } ) ;
190+
191+ test ( "should correctly merge textProps with theme styles" , ( ) => {
192+ renderOtpInput ( {
193+ numberOfDigits : 2 ,
194+ textProps : {
195+ testID : "custom-styled-text" ,
196+ style : { fontWeight : "bold" } ,
197+ } ,
198+ theme : {
199+ pinCodeTextStyle : { fontSize : 20 , color : "blue" } ,
200+ } ,
201+ } ) ;
202+
203+ const input = screen . getByTestId ( "otp-input-hidden" ) ;
204+ fireEvent . changeText ( input , "12" ) ;
205+ const textElement = screen . getByTestId ( "custom-styled-text-0" ) ;
206+ // Check that our custom style from textProps.style is applied
207+ const styles = textElement . props . style ;
208+ const customStyleApplied = styles . some ( ( style : any ) => style . fontWeight === "bold" ) ;
209+ expect ( customStyleApplied ) . toBe ( true ) ;
210+ // Check that theme styles are also applied
211+ const themeStyleApplied = styles . some (
212+ ( style : any ) => style . fontSize === 20 && style . color === "blue"
213+ ) ;
214+ expect ( themeStyleApplied ) . toBe ( true ) ;
215+ } ) ;
216+
167217 test ( 'autoComplete should be set "sms-otp" on Android' , ( ) => {
168218 Platform . OS = "android" ;
169219 renderOtpInput ( ) ;
@@ -361,7 +411,7 @@ describe("OtpInput", () => {
361411 const input = screen . getByTestId ( "otp-input-hidden" ) ;
362412 const otherInput = screen . getByTestId ( "other-input" ) ;
363413 fireEvent . press ( input ) ;
364- // Blur the input
414+ fireEvent . changeText ( input , "" ) ;
365415 fireEvent . press ( otherInput ) ;
366416
367417 const inputs = screen . getAllByTestId ( "otp-input" ) ;
@@ -379,7 +429,6 @@ describe("OtpInput", () => {
379429 const otherInput = screen . getByTestId ( "other-input" ) ;
380430 fireEvent . press ( input ) ;
381431 fireEvent . changeText ( input , "123456" ) ;
382- // Blur the input
383432 fireEvent . press ( otherInput ) ;
384433
385434 const placeholder = screen . queryByText ( "000000" ) ;
0 commit comments