@@ -41,13 +41,11 @@ describe("Tabs", () => {
4141 ] }
4242 /> ,
4343 ) ;
44- // TODO: use a more appropriate attribute once the issue below is addressed:
45- // https://github.com/canonical-web-and-design/vanilla-framework/issues/4481
46- expect ( screen . getByRole ( "link" , { name : "label1" } ) ) . toHaveAttribute (
44+ expect ( screen . getByRole ( "tab" , { name : "label1" } ) ) . toHaveAttribute (
4745 "aria-selected" ,
4846 "true" ,
4947 ) ;
50- expect ( screen . getByRole ( "link " , { name : "label2" } ) ) . toHaveAttribute (
48+ expect ( screen . getByRole ( "tab " , { name : "label2" } ) ) . toHaveAttribute (
5149 "aria-selected" ,
5250 "false" ,
5351 ) ;
@@ -69,9 +67,13 @@ describe("Tabs", () => {
6967 /> ,
7068 ) ;
7169 expect ( screen . getByRole ( "navigation" ) ) . toHaveClass ( "nav-class" ) ;
72- expect ( screen . getByRole ( "list" ) ) . toHaveClass ( "list-class" ) ;
73- expect ( screen . getByRole ( "listitem" ) ) . toHaveClass ( "list-item-class" ) ;
74- expect ( screen . getByRole ( "link" ) ) . toHaveClass ( "link-class" ) ;
70+ expect ( screen . getByRole ( "tablist" ) ) . toHaveClass ( "list-class" ) ;
71+ expect ( screen . getByRole ( "tab" , { name : "label1" } ) ) . toHaveClass (
72+ "link-class" ,
73+ ) ;
74+ expect (
75+ screen . getByRole ( "tab" , { name : "label1" } ) . closest ( "li" ) ,
76+ ) . toHaveClass ( "list-item-class" ) ;
7577 } ) ;
7678
7779 it ( "can use custom elements as links" , ( ) => {
@@ -86,7 +88,7 @@ describe("Tabs", () => {
8688 ] }
8789 /> ,
8890 ) ;
89- expect ( screen . getByRole ( "button " , { name : "label1" } ) ) . toBeInTheDocument ( ) ;
91+ expect ( screen . getByRole ( "tab " , { name : "label1" } ) ) . toBeInTheDocument ( ) ;
9092 } ) ;
9193
9294 it ( "can use custom components as links" , ( ) => {
@@ -109,7 +111,7 @@ describe("Tabs", () => {
109111 /> ,
110112 ) ;
111113
112- expect ( screen . queryByRole ( "link " , { name } ) ) . not . toBeInTheDocument ( ) ;
113- expect ( screen . getByRole ( "button " , { name } ) ) . toBeInTheDocument ( ) ;
114+ expect ( screen . queryByRole ( "button " , { name } ) ) . not . toBeInTheDocument ( ) ;
115+ expect ( screen . getByRole ( "tab " , { name } ) ) . toBeInTheDocument ( ) ;
114116 } ) ;
115117} ) ;
0 commit comments