@@ -294,7 +294,7 @@ describe('<hx-tabset> component tests', () => {
294294 expect ( len ) . to . equal ( 0 ) ;
295295 } ) ;
296296
297- it . skip ( `[FEATURE] should add a dynamic tab with id to empty ${ template } ` , async ( ) => {
297+ it ( `[FEATURE] should add a dynamic tab with id to empty ${ template } ` , async ( ) => {
298298 const mockup = `
299299 <hx-tabset>
300300 <hx-tablist>
@@ -308,26 +308,60 @@ describe('<hx-tabset> component tests', () => {
308308 const tabs = fragment . tabs ;
309309 let firstTabCount = tabs . length ;
310310
311-
312- // add a tab
311+ // add a dyanmic tab
313312 const tab = document . createElement ( 'hx-tab' ) ;
314313 tab . innerHTML = "dynamic tab" ;
315314 fragment . querySelector ( 'hx-tablist' ) . appendChild ( tab ) ;
316315
317316 const tabHasId = fragment . querySelector ( elSelector ) . hasAttribute ( 'id' ) ;
318- //fragment.update(); // manually add tab
319317
320318 // add panel
321319 const tabpanel = document . createElement ( 'hx-tabpanel' ) ;
322320 tabpanel . innerHTML = "dynamic tab panel" ;
323321 fragment . querySelector ( 'hx-tabcontent' ) . appendChild ( tabpanel ) ;
324322 const secoundTabCount = fragment . tabs . length ;
325323
326- // fragment.update(); // manually add tabpanel
324+ fragment . update ( ) ;
327325
328326 expect ( tabHasId ) . to . be . true ;
329327 expect ( firstTabCount ) . to . equal ( 0 ) ;
330328 expect ( secoundTabCount ) . to . equal ( 1 ) ;
331329 } ) ;
330+
331+ it ( `[FEATURE] should add a dynamic tab with id to a populated ${ template } ` , async ( ) => {
332+ const mockup = `
333+ <hx-tabset>
334+ <hx-tablist>
335+ <hx-tab id="dynamicTestTab"></hx-tab>
336+ </hx-tablist>
337+ <hx-tabcontent>
338+ <hx-tabpanel id="dynamicTestTabpanel"></hx-tabpanel>
339+ </hx-tabcontent>
340+ </hx-tabset>` ;
341+
342+ const elSelector = 'hx-tablist > hx-tab' ;
343+ const fragment = /** @type {HXTabsetElement } */ await fixture ( mockup ) ;
344+ const tabs = fragment . tabs ;
345+ let firstTabCount = tabs . length ;
346+
347+ // add a dyanmic tab
348+ const tab = document . createElement ( 'hx-tab' ) ;
349+ tab . innerHTML = "dynamic tab" ;
350+ fragment . querySelector ( 'hx-tablist' ) . appendChild ( tab ) ;
351+
352+ const tabHasId = fragment . querySelector ( elSelector ) . hasAttribute ( 'id' ) ;
353+
354+ // add panel
355+ const tabpanel = document . createElement ( 'hx-tabpanel' ) ;
356+ tabpanel . innerHTML = "dynamic tab panel" ;
357+ fragment . querySelector ( 'hx-tabcontent' ) . appendChild ( tabpanel ) ;
358+ const secoundTabCount = fragment . tabs . length ;
359+
360+ fragment . update ( ) ; // update tab
361+
362+ expect ( tabHasId ) . to . be . true ;
363+ expect ( firstTabCount ) . to . equal ( 1 ) ;
364+ expect ( secoundTabCount ) . to . equal ( 2 ) ;
365+ } ) ;
332366 } ) ;
333367} ) ;
0 commit comments