@@ -210,7 +210,7 @@ describe('TagInput Component', () => {
210210 expect ( wrapper . attributes ( 'placeholder' ) ) . toBe ( 'This is TagInput placeholder' ) ;
211211 } ) ;
212212
213- it ( 'props.readonly works fine' , ( ) => {
213+ it ( 'props.readonly works fine' , async ( ) => {
214214 // readonly default value is false
215215 const wrapper1 = mount ( {
216216 render ( ) {
@@ -225,13 +225,26 @@ describe('TagInput Component', () => {
225225 } ,
226226 } ) . find ( '.t-input' ) ;
227227 expect ( wrapper2 . classes ( 't-is-readonly' ) ) . toBeTruthy ( ) ;
228+
228229 // readonly = false
229230 const wrapper3 = mount ( {
230231 render ( ) {
231232 return < TagInput readonly = { false } > </ TagInput > ;
232233 } ,
233234 } ) . find ( '.t-input' ) ;
234235 expect ( wrapper3 . classes ( 't-is-readonly' ) ) . toBeFalsy ( ) ;
236+ // readonly = false and able backspace
237+ const onRemoveFnOn = vi . fn ( ) ;
238+ const wrapper4 = getTagInputValueMount ( TagInput , { readonly : false } , { remove : onRemoveFnOn } ) ;
239+ wrapper4 . find ( 'input' ) . trigger ( 'keydown.backspace' ) ;
240+ await wrapper4 . vm . $nextTick ( ) ;
241+ expect ( onRemoveFnOn ) . toHaveBeenCalled ( ) ;
242+ // readonly = true and prevent backspace
243+ const onRemoveFnUn = vi . fn ( ) ;
244+ const wrapper5 = getTagInputValueMount ( TagInput , { readonly : true } , { remove : onRemoveFnUn } ) ;
245+ wrapper5 . find ( 'input' ) . trigger ( 'keydown.backspace' ) ;
246+ await wrapper5 . vm . $nextTick ( ) ;
247+ expect ( onRemoveFnUn ) . not . toHaveBeenCalled ( ) ;
235248 } ) ;
236249
237250 it ( 'props.readonly: readonly TagInput does not need clearIcon' , async ( ) => {
0 commit comments