@@ -107,6 +107,7 @@ function testState<T>(input: BaseInput<T>, config: TestConfig, isInit: boolean)
107
107
if ( isInit ) {
108
108
let blurCount = 0 ;
109
109
let focusCount = 0 ;
110
+ let onTouchedCalled = 0 ;
110
111
const subBlur = input . ionBlur . subscribe ( ( ev : any ) => {
111
112
assertEqual ( ev , input , 'ionBlur argument is wrong' ) ;
112
113
blurCount ++ ;
@@ -121,6 +122,15 @@ function testState<T>(input: BaseInput<T>, config: TestConfig, isInit: boolean)
121
122
assert ( false , 'onFocusChange test failed' ) ;
122
123
}
123
124
} ) ;
125
+ input . registerOnTouched ( ( ) => {
126
+ assertEqual ( onTouchedCalled , 0 , 'registerOnTouched: internal error' ) ;
127
+ onTouchedCalled ++ ;
128
+ } ) ;
129
+
130
+ input . _fireBlur ( ) ;
131
+ assertEqual ( blurCount , 0 , 'blur should not have been emitted' ) ;
132
+ assertEqual ( onTouchedCalled , 0 , 'touched should not have been called' ) ;
133
+
124
134
input . _fireFocus ( ) ;
125
135
assertEqual ( input . _isFocus , true , 'should be focus' ) ;
126
136
assertEqual ( input . isFocus ( ) , true , 'should be focus' ) ;
@@ -129,6 +139,7 @@ function testState<T>(input: BaseInput<T>, config: TestConfig, isInit: boolean)
129
139
input . _fireBlur ( ) ;
130
140
assertEqual ( input . _isFocus , false , 'should be not focus' ) ;
131
141
assertEqual ( input . isFocus ( ) , false , 'should be not focus' ) ;
142
+ assertEqual ( onTouchedCalled , 1 , 'touched should have been called' ) ;
132
143
input . _fireBlur ( ) ; // it should not crash
133
144
134
145
assertEqual ( focusCount , 1 , 'ionFocus was not called correctly' ) ;
@@ -166,7 +177,7 @@ function testWriteValue<T>(input: BaseInput<T>, config: TestConfig, isInit: bool
166
177
OnChangeCalled ++ ;
167
178
} ) ;
168
179
169
- // Test registerOnChange
180
+ // Test registerOnTouched
170
181
input . registerOnTouched ( ( ) => {
171
182
assertEqual ( OnTouchedCalled , 0 , 'registerOnTouched: internal error' ) ;
172
183
@@ -187,7 +198,7 @@ function testWriteValue<T>(input: BaseInput<T>, config: TestConfig, isInit: bool
187
198
assertEqual ( ionChangeCalled , 0 , 'loop: ionChange error' ) ;
188
199
}
189
200
assertEqual ( OnChangeCalled , 1 , 'loop: OnChangeCalled was not called' ) ;
190
- assertEqual ( OnTouchedCalled , 1 , 'loop: OnTouchedCalled was not called' ) ;
201
+ assertEqual ( OnTouchedCalled , 0 , 'loop: OnTouchedCalled was called' ) ;
191
202
192
203
OnTouchedCalled = OnChangeCalled = ionChangeCalled = 0 ;
193
204
@@ -212,7 +223,7 @@ function testWriteValue<T>(input: BaseInput<T>, config: TestConfig, isInit: bool
212
223
input . value = null ;
213
224
assertEqual ( input . value , config . defaultValue , 'null: wrong default value' ) ;
214
225
assertEqual ( OnChangeCalled , 1 , 'null: OnChangeCalled was not called' ) ;
215
- assertEqual ( OnTouchedCalled , 1 , 'null: OnTouchedCalled was not called' ) ;
226
+ assertEqual ( OnTouchedCalled , 0 , 'null: OnTouchedCalled was called' ) ;
216
227
217
228
218
229
input . registerOnChange ( null ) ;
0 commit comments