File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ function TextInputWithMask(
8787 onChange = { ( e ) => {
8888 onChange && onChange ( e )
8989 } }
90- maxLength = { 10 }
90+ maxLength = { mask . length }
9191 right = { inputButton }
9292 />
9393 )
Original file line number Diff line number Diff line change 1+ import { render } from '@testing-library/react-native'
2+ import TextInputWithMask from '../TextInputMask'
3+
4+ const noop = ( ) => null
5+
6+ describe ( 'TextInputMask' , ( ) => {
7+ it ( 'should set maxLength based on mask length for standard format' , ( ) => {
8+ const { getByTestId } = render (
9+ < TextInputWithMask
10+ testID = "date-input"
11+ value = ""
12+ mask = "MM/DD/YYYY"
13+ inputButton = { null }
14+ onChangeText = { noop }
15+ />
16+ )
17+ const input = getByTestId ( 'date-input' )
18+ expect ( input . props . maxLength ) . toBe ( 10 )
19+ } )
20+
21+ it ( 'should set maxLength based on mask length for Czech locale format' , ( ) => {
22+ const { getByTestId } = render (
23+ < TextInputWithMask
24+ testID = "date-input"
25+ value = ""
26+ mask = "DD. MM. YYYY"
27+ inputButton = { null }
28+ onChangeText = { noop }
29+ />
30+ )
31+ const input = getByTestId ( 'date-input' )
32+ expect ( input . props . maxLength ) . toBe ( 12 )
33+ } )
34+
35+ it ( 'should set maxLength based on mask length for Hungarian locale format' , ( ) => {
36+ const { getByTestId } = render (
37+ < TextInputWithMask
38+ testID = "date-input"
39+ value = ""
40+ mask = "YYYY. MM. DD."
41+ inputButton = { null }
42+ onChangeText = { noop }
43+ />
44+ )
45+ const input = getByTestId ( 'date-input' )
46+ expect ( input . props . maxLength ) . toBe ( 13 )
47+ } )
48+
49+ it ( 'should set maxLength based on mask length for German locale format' , ( ) => {
50+ const { getByTestId } = render (
51+ < TextInputWithMask
52+ testID = "date-input"
53+ value = ""
54+ mask = "DD.MM.YYYY"
55+ inputButton = { null }
56+ onChangeText = { noop }
57+ />
58+ )
59+ const input = getByTestId ( 'date-input' )
60+ expect ( input . props . maxLength ) . toBe ( 10 )
61+ } )
62+ } )
You can’t perform that action at this time.
0 commit comments