@@ -304,6 +304,71 @@ describe('UUIMenuItemElement', () => {
304304 labelElement ?. click ( ) ;
305305 expect ( element . selected ) . to . be . false ;
306306 } ) ;
307+
308+ it ( 'can expand' , async ( ) => {
309+ element . setAttribute ( 'has-children' , 'true' ) ;
310+ await elementUpdated ( element ) ;
311+ const listener = oneEvent ( element , 'show-children' ) ;
312+ const caretIconElement : HTMLElement | null =
313+ element . shadowRoot ! . querySelector ( '#caret-button' ) ;
314+ caretIconElement ?. click ( ) ;
315+ const event = await listener ;
316+ expect ( event ) . to . exist ;
317+ expect ( event . type ) . to . equal ( 'show-children' ) ;
318+ expect ( element . hasAttribute ( 'show-children' ) ) . to . equal ( true ) ;
319+ } ) ;
320+ } ) ;
321+
322+ describe ( 'selectable & selectOnly' , ( ) => {
323+ let labelElement : HTMLElement | null ;
324+
325+ beforeEach ( async ( ) => {
326+ labelElement = element . shadowRoot ! . querySelector ( '#label-button' ) ;
327+ element . selectable = true ;
328+ element . selectOnly = true ;
329+ } ) ;
330+
331+ it ( 'label element is defined' , ( ) => {
332+ expect ( labelElement ) . to . be . instanceOf ( HTMLElement ) ;
333+ } ) ;
334+
335+ it ( 'label is rendered as a button tag' , async ( ) => {
336+ await elementUpdated ( element ) ;
337+ expect ( labelElement ?. nodeName ) . to . be . equal ( 'BUTTON' ) ;
338+ } ) ;
339+
340+ it ( 'can be selected when selectable' , async ( ) => {
341+ await elementUpdated ( element ) ;
342+ labelElement ?. click ( ) ;
343+ expect ( element . selected ) . to . be . true ;
344+ } ) ;
345+
346+ it ( 'can not be selected when not selectable' , async ( ) => {
347+ element . selectable = false ;
348+ await elementUpdated ( element ) ;
349+ labelElement ?. click ( ) ;
350+ expect ( element . selected ) . to . be . false ;
351+ } ) ;
352+
353+ it ( 'can be selected when selectable' , async ( ) => {
354+ element . disabled = true ;
355+ await elementUpdated ( element ) ;
356+ labelElement ?. click ( ) ;
357+ expect ( element . selected ) . to . be . false ;
358+ } ) ;
359+
360+ it ( 'can expand' , async ( ) => {
361+ element . setAttribute ( 'has-children' , 'true' ) ;
362+ await elementUpdated ( element ) ;
363+ const listener = oneEvent ( element , 'show-children' ) ;
364+ const caretIconElement : HTMLElement | null =
365+ element . shadowRoot ! . querySelector ( '#caret-button' ) ;
366+ caretIconElement ?. click ( ) ;
367+ const event = await listener ;
368+ expect ( event ) . to . exist ;
369+ expect ( event . type ) . to . equal ( 'show-children' ) ;
370+ expect ( element . hasAttribute ( 'show-children' ) ) . to . equal ( true ) ;
371+ } ) ;
307372 } ) ;
308373
309374 describe ( 'HREF' , ( ) => {
0 commit comments