@@ -42,10 +42,7 @@ public async Task IsAsync_Ok()
4242 pb . Add ( a => a . IsAsync , true ) ;
4343 pb . Add ( a => a . IsKeepDisabled , false ) ;
4444 pb . Add ( a => a . Icon , "fa-solid fa-test-icon" ) ;
45- pb . Add ( a => a . OnClickWithoutRender , ( ) =>
46- {
47- return Task . CompletedTask ;
48- } ) ;
45+ pb . Add ( a => a . OnClickWithoutRender , ( ) => Task . CompletedTask ) ;
4946 } ) ;
5047 cut . Contains ( "<i class=\" fa-solid fa-test-icon\" ></i>" ) ;
5148 var button = cut . Find ( "button" ) ;
@@ -272,16 +269,66 @@ public void Disabled_Ok()
272269 }
273270
274271 [ Fact ]
275- public void ItemsTemplate_Ok ( )
272+ public async Task ItemsTemplate_Ok ( )
276273 {
274+ var clicked = false ;
277275 var cut = Context . RenderComponent < Dropdown < string > > ( pb =>
278276 {
279- pb . Add ( a => a . ItemsTemplate , new RenderFragment ( builder =>
277+ pb . Add ( a => a . IsFixedButtonText , true ) ;
278+ pb . Add ( a => a . FixedButtonText , "fixed text" ) ;
279+ pb . Add ( a => a . ItemsTemplate , builder =>
280280 {
281- builder . AddContent ( 0 , new MarkupString ( "<div>test-items-template</div>" ) ) ;
282- } ) ) ;
281+ builder . OpenComponent < DropdownItem > ( 0 ) ;
282+ builder . AddAttribute ( 1 , "Icon" , "fa-solid fa-icon1" ) ;
283+ builder . AddAttribute ( 2 , "Text" , "dropdown-item-test1" ) ;
284+ builder . AddAttribute ( 3 , "OnClick" , ( ) =>
285+ {
286+ clicked = true ;
287+ return Task . CompletedTask ;
288+ } ) ;
289+ builder . CloseComponent ( ) ;
290+
291+ builder . OpenComponent < DropdownItem > ( 0 ) ;
292+ builder . AddAttribute ( 1 , "Icon" , "fa-solid fa-icon2" ) ;
293+ builder . AddAttribute ( 2 , "Text" , "dropdown-item-test2" ) ;
294+ builder . AddAttribute ( 3 , "Disabled" , true ) ;
295+ builder . CloseComponent ( ) ;
296+
297+ builder . OpenComponent < DropdownItem > ( 0 ) ;
298+ builder . AddAttribute ( 1 , "Icon" , "fa-solid fa-icon3" ) ;
299+ builder . AddAttribute ( 2 , "Text" , "dropdown-item-test3" ) ;
300+ builder . AddAttribute ( 3 , "Disabled" , false ) ;
301+ builder . AddAttribute ( 4 , "OnDisabledCallback" , ( ) => true ) ;
302+ builder . CloseComponent ( ) ;
303+
304+ builder . OpenComponent < DropdownItem > ( 0 ) ;
305+ builder . AddAttribute ( 1 , "Icon" , "fa-solid fa-icon4" ) ;
306+ builder . AddAttribute ( 2 , "Text" , "dropdown-item-test4" ) ;
307+ builder . AddAttribute ( 3 , "ChildContent" ,
308+ new RenderFragment ( pb1 => pb1 . AddMarkupContent ( 0 , "<div>dropdown-item-childcontent</div>" ) ) ) ;
309+ builder . CloseComponent ( ) ;
310+ } ) ;
283311 } ) ;
284- cut . Contains ( "<div>test-items-template</div>" ) ;
312+ cut . Contains ( "fa-solid fa-icon1" ) ;
313+ cut . Contains ( "dropdown-item-test1" ) ;
314+
315+ cut . Contains ( "fa-solid fa-icon2" ) ;
316+ cut . Contains ( "dropdown-item-test2" ) ;
317+
318+ cut . Contains ( "fa-solid fa-icon3" ) ;
319+ cut . Contains ( "dropdown-item-test3" ) ;
320+
321+ cut . DoesNotContain ( "fa-solid fa-icon4" ) ;
322+ cut . DoesNotContain ( "dropdown-item-test4" ) ;
323+ cut . Contains ( "dropdown-item-childcontent" ) ;
324+
325+ cut . Contains ( "dropdown-item disabled" ) ;
326+
327+ Assert . False ( clicked ) ;
328+
329+ var item = cut . Find ( ".dropdown-item" ) ;
330+ await cut . InvokeAsync ( ( ( ) => item . Click ( ) ) ) ;
331+ Assert . True ( clicked ) ;
285332 }
286333
287334 [ Fact ]
0 commit comments