File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 55
66using Microsoft . AspNetCore . Components . Web ;
77using Microsoft . Extensions . Localization ;
8+ using System ;
89
910namespace UnitTest . Components ;
1011
@@ -495,4 +496,30 @@ public async Task ToogleButton_Ok()
495496 Assert . True ( clickWithoutRender ) ;
496497 Assert . True ( clicked ) ;
497498 }
499+
500+ [ Fact ]
501+ public async Task ToggleButton_IsAsync ( )
502+ {
503+ var active = false ;
504+ var tcs = new TaskCompletionSource ( ) ;
505+ var cut = Context . RenderComponent < ToggleButton > ( pb =>
506+ {
507+ pb . Add ( a => a . IsAsync , true ) ;
508+ pb . Add ( a => a . Icon , "fa-solid fa-test" ) ;
509+ pb . Add ( a => a . Text , "toggle-button" ) ;
510+ pb . Add ( a => a . OnClick , async ( ) =>
511+ {
512+ await Task . Delay ( 100 ) ;
513+ } ) ;
514+ pb . Add ( a => a . OnToggleAsync , isActive =>
515+ {
516+ active = isActive ;
517+ tcs . TrySetResult ( ) ;
518+ return Task . CompletedTask ;
519+ } ) ;
520+ } ) ;
521+ var button = cut . Find ( "button" ) ;
522+ await cut . InvokeAsync ( ( ) => button . Click ( ) ) ;
523+ await tcs . Task ;
524+ }
498525}
You can’t perform that action at this time.
0 commit comments