@@ -547,7 +547,7 @@ public void CollapsedTopSearch_Ok()
547547 }
548548
549549 [ Fact ]
550- public void UseSearchForm_Ok ( )
550+ public async Task UseSearchForm_Ok ( )
551551 {
552552 var localizer = Context . Services . GetRequiredService < IStringLocalizer < Foo > > ( ) ;
553553 var cut = Context . Render < BootstrapBlazorRoot > ( pb =>
@@ -586,16 +586,55 @@ public void UseSearchForm_Ok()
586586 builder . AddAttribute ( 3 , nameof ( ITableColumn . Searchable ) , true ) ;
587587 builder . CloseComponent ( ) ;
588588
589+ builder . OpenComponent < TableColumn < Foo , IEnumerable < string > > > ( 0 ) ;
590+ builder . AddAttribute ( 1 , "Field" , Enumerable . Empty < string > ( ) ) ;
591+ builder . AddAttribute ( 2 , "FieldExpression" , Utility . GenerateValueExpression ( foo , nameof ( Foo . Hobby ) , typeof ( IEnumerable < string > ) ) ) ;
592+ builder . AddAttribute ( 3 , nameof ( ITableColumn . Searchable ) , true ) ;
593+ builder . CloseComponent ( ) ;
594+
595+ builder . OpenComponent < TableColumn < Foo , EnumEducation ? > > ( 0 ) ;
596+ builder . AddAttribute ( 1 , "Field" , EnumEducation . Middle ) ;
597+ builder . AddAttribute ( 2 , "FieldExpression" , Utility . GenerateValueExpression ( foo , nameof ( Foo . Education ) , typeof ( EnumEducation ? ) ) ) ;
598+ builder . AddAttribute ( 3 , nameof ( ITableColumn . Searchable ) , true ) ;
599+ builder . AddAttribute ( 4 , nameof ( ITableColumn . Lookup ) , new List < SelectedItem > ( )
600+ {
601+ new SelectedItem ( "" , "全部" ) ,
602+ new SelectedItem ( "1" , "中学" ) ,
603+ } ) ;
604+ builder . CloseComponent ( ) ;
605+
589606 builder . OpenComponent < TableColumn < Foo , bool > > ( 0 ) ;
590607 builder . AddAttribute ( 1 , "Field" , true ) ;
591608 builder . AddAttribute ( 2 , "FieldExpression" , Utility . GenerateValueExpression ( foo , nameof ( Foo . Complete ) , typeof ( bool ) ) ) ;
592609 builder . AddAttribute ( 3 , nameof ( ITableColumn . Searchable ) , true ) ;
593610 builder . CloseComponent ( ) ;
611+
612+ builder . OpenComponent < TableColumn < Foo , bool > > ( 0 ) ;
613+ builder . AddAttribute ( 1 , "Field" , true ) ;
614+ builder . AddAttribute ( 2 , "FieldExpression" , Utility . GenerateValueExpression ( foo , nameof ( Foo . Complete ) , typeof ( bool ) ) ) ;
615+ builder . AddAttribute ( 3 , nameof ( ITableColumn . Searchable ) , true ) ;
616+ builder . AddAttribute ( 3 , nameof ( ITableColumn . SearchFormItemMetaData ) , new StringSearchMetaData ( ) ) ;
617+ builder . CloseComponent ( ) ;
594618 } ) ;
595619 } ) ;
596620 } ) ;
597621
598622 cut . Contains ( "bb-editor bb-search-form" ) ;
623+
624+ // 触发 Filter
625+ var searchForm = cut . FindComponent < SearchForm > ( ) ;
626+ Assert . NotNull ( searchForm ) ;
627+
628+ var input = searchForm . FindComponent < BootstrapInput < string > > ( ) ;
629+ Assert . NotNull ( input ) ;
630+
631+ var cb = input . Instance . OnValueChanged ;
632+ Assert . NotNull ( cb ) ;
633+ await cb ( "test" ) ;
634+
635+ var table = cut . FindComponent < Table < Foo > > ( ) ;
636+ Assert . NotNull ( table ) ;
637+ await cut . InvokeAsync ( ( ) => table . Instance . QueryAsync ( ) ) ;
599638 }
600639
601640 [ Fact ]
0 commit comments