@@ -181,7 +181,45 @@ public void HeaderColor_OK()
181181 Assert . NotNull ( ele ) ;
182182 }
183183
184- private static IEnumerable < DropdownWidgetItem > GetItems ( )
184+ [ Fact ]
185+ public async Task OnItemAsync_OK ( )
186+ {
187+ var shown = false ;
188+ var closed = false ;
189+ var cut = Context . RenderComponent < DropdownWidget > ( builder =>
190+ {
191+ builder . Add ( a => a . OnItemShownAsync , item =>
192+ {
193+ shown = true ;
194+ return Task . CompletedTask ;
195+ } ) ;
196+ builder . Add ( a => a . OnItemCloseAsync , item =>
197+ {
198+ closed = true ;
199+ return Task . CompletedTask ;
200+ } ) ;
201+ builder . Add ( s => s . ChildContent , new RenderFragment ( builder =>
202+ {
203+ builder . OpenComponent < DropdownWidgetItem > ( 0 ) ;
204+ builder . AddAttribute ( 1 , nameof ( DropdownWidgetItem . HeaderColor ) , Color . Success ) ;
205+ builder . AddAttribute ( 2 , nameof ( DropdownWidgetItem . Title ) , "Test1" ) ;
206+ builder . CloseComponent ( ) ;
207+
208+ builder . OpenComponent < DropdownWidgetItem > ( 0 ) ;
209+ builder . AddAttribute ( 10 , nameof ( DropdownWidgetItem . HeaderColor ) , Color . Success ) ;
210+ builder . AddAttribute ( 11 , nameof ( DropdownWidgetItem . Title ) , "Test2" ) ;
211+ builder . CloseComponent ( ) ;
212+ } ) ) ;
213+ } ) ;
214+
215+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerStateChanged ( 0 , true ) ) ;
216+ Assert . True ( shown ) ;
217+
218+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerStateChanged ( 1 , false ) ) ;
219+ Assert . True ( closed ) ;
220+ }
221+
222+ private static List < DropdownWidgetItem > GetItems ( )
185223 {
186224 var ret = new List < DropdownWidgetItem > ( ) ;
187225 var widget = new DropdownWidgetItem ( ) ;
0 commit comments