@@ -7,6 +7,7 @@ import { user } from "../setup-tests";
77import Tab from "./Tab.test.svelte" ;
88import TabIcon from "./TabIcon.test.svelte" ;
99import TabIconContainer from "./TabIconContainer.test.svelte" ;
10+ import TabIconSecondaryLabel from "./TabIconSecondaryLabel.test.svelte" ;
1011import TabSecondaryLabel from "./TabSecondaryLabel.test.svelte" ;
1112import Tabs from "./Tabs.test.svelte" ;
1213import TabsDynamic from "./TabsDynamic.test.svelte" ;
@@ -521,6 +522,70 @@ describe("Container tabs with icon", () => {
521522 } ) ;
522523} ) ;
523524
525+ describe ( "Container tabs with icons and secondary label" , ( ) => {
526+ it ( "should render container type with icon and secondary label on each tab" , ( ) => {
527+ const { container } = render ( TabIconSecondaryLabel ) ;
528+
529+ const tabsContainer = screen . getByRole ( "navigation" ) ;
530+ expect ( tabsContainer ) . toHaveClass ( "bx--tabs--container" ) ;
531+
532+ expect ( screen . getByRole ( "tab" , { name : / C a l e n d a r / } ) ) . toBeInTheDocument ( ) ;
533+ expect ( screen . getByText ( "(12 events)" ) ) . toBeInTheDocument ( ) ;
534+
535+ expect (
536+ screen . getByRole ( "tab" , { name : / I n f o r m a t i o n / } ) ,
537+ ) . toBeInTheDocument ( ) ;
538+ expect ( screen . getByText ( "(3 new)" ) ) . toBeInTheDocument ( ) ;
539+
540+ expect ( screen . getByRole ( "tab" , { name : / S e t t i n g s / } ) ) . toBeInTheDocument ( ) ;
541+ expect ( screen . getByText ( "(2 pending)" ) ) . toBeInTheDocument ( ) ;
542+
543+ const iconWrappers = container . querySelectorAll (
544+ ".bx--tabs__nav-item--icon" ,
545+ ) ;
546+ expect ( iconWrappers ) . toHaveLength ( 3 ) ;
547+ } ) ;
548+
549+ it ( "should have label wrapper and secondary label when tab has icon and secondaryLabel" , ( ) => {
550+ const { container } = render ( TabIconSecondaryLabel ) ;
551+
552+ const navItems = container . querySelectorAll ( ".bx--tabs__nav-item" ) ;
553+ const calendarTab = navItems [ 0 ] ;
554+ const labelWrapper = calendarTab ?. querySelector (
555+ ".bx--tabs__nav-item-label-wrapper" ,
556+ ) ;
557+ const secondaryLabel = calendarTab ?. querySelector (
558+ ".bx--tabs__nav-item-secondary-label" ,
559+ ) ;
560+ const iconWrapper = calendarTab ?. querySelector ( ".bx--tabs__nav-item--icon" ) ;
561+
562+ expect ( labelWrapper ) . toBeInTheDocument ( ) ;
563+ expect ( secondaryLabel ) . toBeInTheDocument ( ) ;
564+ expect ( secondaryLabel ) . toHaveTextContent ( "(12 events)" ) ;
565+ expect ( iconWrapper ) . toBeInTheDocument ( ) ;
566+ } ) ;
567+
568+ it ( "should be clickable and show content when tab has icon and secondary label" , async ( ) => {
569+ render ( TabIconSecondaryLabel ) ;
570+
571+ const informationTab = screen . getByRole ( "tab" , { name : / I n f o r m a t i o n / } ) ;
572+ await user . click ( informationTab ) ;
573+
574+ expect ( informationTab ) . toHaveAttribute ( "aria-selected" , "true" ) ;
575+ expect ( screen . getByText ( "Information content" ) ) . toBeVisible ( ) ;
576+ } ) ;
577+
578+ it ( "should not select disabled tab with icon and secondary label" , async ( ) => {
579+ render ( TabIconSecondaryLabel ) ;
580+
581+ const settingsTab = screen . getByRole ( "tab" , { name : / S e t t i n g s / } ) ;
582+ expect ( settingsTab ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
583+ await user . click ( settingsTab ) ;
584+
585+ expect ( settingsTab ) . toHaveAttribute ( "aria-selected" , "false" ) ;
586+ } ) ;
587+ } ) ;
588+
524589describe ( "Container tabs with secondary label" , ( ) => {
525590 it ( "should render container with tall class when any tab has secondary label" , ( ) => {
526591 render ( TabSecondaryLabel ) ;
0 commit comments