File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,38 @@ namespace UnitTest.Components;
1212
1313public class SelectTest : BootstrapBlazorTestBase
1414{
15+ [ Fact ]
16+ public async Task IsUseActiveWhenValueNull_Ok ( )
17+ {
18+ var tcs = new TaskCompletionSource ( ) ;
19+ var selectedValue = "" ;
20+ var cut = Context . RenderComponent < BootstrapBlazorRoot > ( pb =>
21+ {
22+ pb . AddChildContent < Select < string > > ( pb =>
23+ {
24+ pb . Add ( a => a . ShowSearch , true ) ;
25+ pb . Add ( a => a . Items , new List < SelectedItem > ( )
26+ {
27+ new ( "1" , "Test1" ) ,
28+ new ( "2" , "Test2" ) { Active = true }
29+ } ) ;
30+ pb . Add ( a => a . IsUseActiveWhenValueIsNull , true ) ;
31+ pb . Add ( a => a . OnSelectedItemChanged , item =>
32+ {
33+ selectedValue = item . Value ;
34+ tcs . SetResult ( ) ;
35+ return Task . CompletedTask ;
36+ } ) ;
37+ } ) ;
38+ } ) ;
39+
40+ await tcs . Task ;
41+
42+ // 组件未设置 Value 参数,应该使用 Test2 作为初始选项,并且触发 SelectedItemChanged 回调
43+ Assert . Equal ( "2" , selectedValue ) ;
44+ cut . Contains ( "value=\" Test2\" " ) ;
45+ }
46+
1547 [ Fact ]
1648 public async Task OnSearchTextChanged_Null ( )
1749 {
You can’t perform that action at this time.
0 commit comments