77using Bunit . TestDoubles ;
88using Microsoft . AspNetCore . Components . Rendering ;
99using System . Reflection ;
10+ using System . Threading . Tasks ;
1011using UnitTest . Misc ;
1112
1213namespace UnitTest . Components ;
@@ -25,6 +26,46 @@ protected override void ConfigureServices(IServiceCollection services)
2526 } ) ;
2627 }
2728
29+ [ Fact ]
30+ public async Task ContextMenu_Ok ( )
31+ {
32+ var clicked = false ;
33+ var cut = Context . RenderComponent < ContextMenuZone > ( pb =>
34+ {
35+ pb . AddChildContent < Tab > ( pb =>
36+ {
37+ pb . AddChildContent < TabItem > ( pb =>
38+ {
39+ pb . Add ( a => a . Text , "Tab1" ) ;
40+ pb . Add ( a => a . Url , "/Index" ) ;
41+ pb . Add ( a => a . Closable , true ) ;
42+ pb . Add ( a => a . Icon , "fa-solid fa-font-awesome" ) ;
43+ pb . Add ( a => a . ChildContent , "Tab1-Content" ) ;
44+ } ) ;
45+ } ) ;
46+ pb . AddChildContent < ContextMenu > ( pb =>
47+ {
48+ pb . AddChildContent < ContextMenuItem > ( pb =>
49+ {
50+ pb . Add ( a => a . Text , "test-close" ) ;
51+ pb . Add ( a => a . OnClick , ( context , item ) =>
52+ {
53+ clicked = true ;
54+ if ( item is TabItem tabItem )
55+ {
56+
57+ }
58+ return Task . CompletedTask ;
59+ } ) ;
60+ } ) ;
61+ } ) ;
62+ } ) ;
63+
64+ var item = cut . Find ( ".dropdown-menu .dropdown-item" ) ;
65+ await cut . InvokeAsync ( ( ) => item . Click ( ) ) ;
66+ Assert . True ( clicked ) ;
67+ }
68+
2869 [ Fact ]
2970 public void ToolbarTemplate_Ok ( )
3071 {
0 commit comments