@@ -147,24 +147,48 @@ describe('DatePicker', () => {
147147 expect ( onCloseModal ) . toHaveBeenCalledTimes ( 1 ) ;
148148 } ) ;
149149
150- it ( 'onPressMask' , ( ) => {
151- const onPressMask = jest . fn ( ) ;
152- const wrapper = shallow ( < DatePicker onPressMask = { onPressMask } /> ) ;
153- const datePicker = wrapper . instance ( ) ;
154-
155- datePicker . onPressMask ( ) ;
156-
157- expect ( onPressMask ) . toHaveBeenCalledTimes ( 1 ) ;
158-
159- // call onPressCancel when without onPressMask cb func
160- const onPressCancel = jest . fn ( ) ;
161- const wrapper1 = shallow ( < DatePicker /> ) ;
162- const datePicker1 = wrapper1 . instance ( ) ;
163- datePicker1 . onPressCancel = onPressCancel ;
164-
165- datePicker1 . onPressMask ( ) ;
166-
167- expect ( onPressCancel ) . toHaveBeenCalledTimes ( 1 ) ;
150+ describe ( 'onPressMask' , ( ) => {
151+ it ( 'calls onPressMask if onPressMask is passed' , ( ) => {
152+ const onPressMask = jest . fn ( ) ;
153+ const wrapper = shallow ( < DatePicker onPressMask = { onPressMask } /> ) ;
154+ const datePicker = wrapper . instance ( ) ;
155+
156+ datePicker . onPressMask ( ) ;
157+
158+ expect ( onPressMask ) . toHaveBeenCalledTimes ( 1 ) ;
159+ } )
160+
161+ it ( 'calls onPressCancel if onPressMask is not passed' , ( ) => {
162+ const onPressCancel = jest . fn ( ) ;
163+ const wrapper = shallow ( < DatePicker /> ) ;
164+ const datePicker = wrapper . instance ( ) ;
165+ datePicker . onPressCancel = onPressCancel ;
166+
167+ datePicker . onPressMask ( ) ;
168+
169+ expect ( onPressCancel ) . toHaveBeenCalledTimes ( 1 ) ;
170+ } )
171+
172+ it ( 'calls onPressCancel when onPressMaskBehaviour is set to cancel and onPressMask is not passed' , ( ) => {
173+ const onPressCancel = jest . fn ( ) ;
174+ const wrapper = shallow ( < DatePicker onPressMaskBehaviour = 'cancel' /> ) ;
175+ const datePicker = wrapper . instance ( ) ;
176+ datePicker . onPressCancel = onPressCancel ;
177+
178+ datePicker . onPressMask ( ) ;
179+
180+ expect ( onPressCancel ) . toHaveBeenCalledTimes ( 1 ) ;
181+ } )
182+ it ( 'calls onPressConfirm when onPressMaskBehaviour is set to confirm and onPressMask is not passed' , ( ) => {
183+ const onPressConfirm = jest . fn ( ) ;
184+ const wrapper = shallow ( < DatePicker onPressMaskBehaviour = 'confirm' /> ) ;
185+ const datePicker = wrapper . instance ( ) ;
186+ datePicker . onPressConfirm = onPressConfirm ;
187+
188+ datePicker . onPressMask ( ) ;
189+
190+ expect ( onPressConfirm ) . toHaveBeenCalledTimes ( 1 ) ;
191+ } )
168192 } ) ;
169193
170194 it ( 'onPressConfirm' , ( ) => {
0 commit comments