@@ -346,3 +346,51 @@ describe('AutoComplete control Error Tests', () => {
346346 ) . toBe ( 'Hi, this is me, test error!' ) ;
347347 } ) ;
348348} ) ;
349+
350+ describe ( 'AutoComplete control updateFilter function' , ( ) => {
351+ let fixture : ComponentFixture < AutocompleteControlRenderer > ;
352+ let component : AutocompleteControlRenderer ;
353+
354+ beforeEach ( ( ) => {
355+ TestBed . configureTestingModule ( {
356+ declarations : [ componentUT ] ,
357+ imports : imports ,
358+ providers : providers ,
359+ } ) . compileComponents ( ) ;
360+ } ) ;
361+
362+ beforeEach ( ( ) => {
363+ fixture = TestBed . createComponent ( componentUT ) ;
364+ component = fixture . componentInstance ;
365+ } ) ;
366+
367+ it ( 'should not filter options on ENTER key press' , ( ) => {
368+ component . shouldFilter = false ;
369+ component . options = [ 'X' , 'Y' , 'Z' ] ;
370+ setupMockStore ( fixture , { uischema, schema, data } ) ;
371+ getJsonFormsService ( component ) . updateCore (
372+ Actions . init ( data , schema , uischema )
373+ ) ;
374+ component . ngOnInit ( ) ;
375+ fixture . detectChanges ( ) ;
376+ component . updateFilter ( { keyCode : 13 } ) ;
377+ fixture . detectChanges ( ) ;
378+ expect ( component . shouldFilter ) . toBe ( false ) ;
379+ } ) ;
380+
381+ it ( 'should filter options when a key other than ENTER is pressed' , ( ) => {
382+ component . shouldFilter = false ;
383+ component . options = [ 'X' , 'Y' , 'Z' ] ;
384+ setupMockStore ( fixture , { uischema, schema, data } ) ;
385+ getJsonFormsService ( component ) . updateCore (
386+ Actions . init ( data , schema , uischema )
387+ ) ;
388+ component . ngOnInit ( ) ;
389+ fixture . detectChanges ( ) ;
390+
391+ component . updateFilter ( { keyCode : 65 } ) ;
392+ fixture . detectChanges ( ) ;
393+
394+ expect ( component . shouldFilter ) . toBe ( true ) ;
395+ } ) ;
396+ } ) ;
0 commit comments