@@ -52,6 +52,8 @@ describe("<pfe-accordion>", () => {
5252 assert . equal ( true , header . expanded ) ;
5353 assert . isTrue ( panel . hasAttribute ( 'expanded' ) ) ;
5454 assert . isTrue ( panel . expanded ) ;
55+ assert . isTrue ( panel . hasAttribute ( 'expanded' ) ) ;
56+ assert . isTrue ( panel . expanded ) ;
5557 } ) ;
5658
5759 it ( 'should collapse a panel when an already expanded header is selected' , async ( ) => {
@@ -69,6 +71,8 @@ describe("<pfe-accordion>", () => {
6971 assert . equal ( false , header . expanded ) ;
7072 assert . isFalse ( panel . hasAttribute ( 'expanded' ) ) ;
7173 assert . isFalse ( panel . expanded ) ;
74+ assert . isTrue ( panel . getAttribute ( "aria-hidden" ) == "true" ) ;
75+ assert . isTrue ( panel . getAttribute ( "tabindex" ) == "-1" ) ;
7276 } ) ;
7377
7478 it ( 'should randomly generate ids for aria use' , async ( ) => {
@@ -101,13 +105,17 @@ describe("<pfe-accordion>", () => {
101105 assert . equal ( true , secondHeader . expanded ) ;
102106 assert . isTrue ( secondPanel . hasAttribute ( 'expanded' ) ) ;
103107 assert . isTrue ( secondPanel . expanded ) ;
108+ assert . isFalse ( secondPanel . hasAttribute ( "aria-hidden" ) ) ;
109+ assert . isFalse ( secondPanel . hasAttribute ( "tabindex" ) ) ;
104110
105111 pfeAccordion . toggle ( 1 ) ;
106112
107113 assert . isTrue ( secondHeader . button . getAttribute ( 'aria-expanded' ) == "false" ) ;
108114 assert . equal ( false , secondHeader . expanded ) ;
109115 assert . isFalse ( secondPanel . hasAttribute ( 'expanded' ) ) ;
110116 assert . isFalse ( secondPanel . expanded ) ;
117+ assert . isTrue ( secondPanel . getAttribute ( "aria-hidden" ) == "true" ) ;
118+ assert . isTrue ( secondPanel . getAttribute ( "tabindex" ) == "-1" ) ;
111119 } ) ;
112120
113121 it ( 'should expand a panel when expand is called' , async ( ) => {
@@ -121,6 +129,8 @@ describe("<pfe-accordion>", () => {
121129 assert . equal ( true , secondHeader . expanded ) ;
122130 assert . isTrue ( secondPanel . hasAttribute ( 'expanded' ) ) ;
123131 assert . isTrue ( secondPanel . expanded ) ;
132+ assert . isFalse ( secondPanel . hasAttribute ( "aria-hidden" ) ) ;
133+ assert . isFalse ( secondPanel . hasAttribute ( "tabindex" ) ) ;
124134 } ) ;
125135
126136 it ( 'should collapse a panel when collapse is called' , async ( ) => {
@@ -135,6 +145,8 @@ describe("<pfe-accordion>", () => {
135145 assert . equal ( false , secondHeader . expanded ) ;
136146 assert . isFalse ( secondPanel . hasAttribute ( 'expanded' ) ) ;
137147 assert . isFalse ( secondPanel . expanded ) ;
148+ assert . isTrue ( secondPanel . getAttribute ( "aria-hidden" ) == "true" ) ;
149+ assert . isTrue ( secondPanel . getAttribute ( "tabindex" ) == "-1" ) ;
138150 } ) ;
139151
140152 it ( 'should expand all panels when expandAll is called' , async ( ) => {
@@ -152,6 +164,8 @@ describe("<pfe-accordion>", () => {
152164 panels . forEach ( panel => {
153165 assert . isTrue ( panel . hasAttribute ( 'expanded' ) ) ;
154166 assert . isTrue ( panel . expanded ) ;
167+ assert . isFalse ( panel . hasAttribute ( "aria-hidden" ) ) ;
168+ assert . isFalse ( panel . hasAttribute ( "tabindex" ) ) ;
155169 } ) ;
156170 } ) ;
157171
@@ -171,6 +185,8 @@ describe("<pfe-accordion>", () => {
171185 panels . forEach ( panel => {
172186 assert . isFalse ( panel . hasAttribute ( 'expanded' ) ) ;
173187 assert . isFalse ( panel . expanded ) ;
188+ assert . isTrue ( panel . getAttribute ( "aria-hidden" ) == "true" ) ;
189+ assert . isTrue ( panel . getAttribute ( "tabindex" ) == "-1" ) ;
174190 } ) ;
175191 } ) ;
176192
@@ -224,6 +240,8 @@ describe("<pfe-accordion>", () => {
224240 const panel = pfeAccordion . _panelForHeader ( header ) ;
225241 assert . isTrue ( panel . expanded ) ;
226242 assert . isTrue ( panel . hasAttribute ( "expanded" ) ) ;
243+ assert . isFalse ( panel . hasAttribute ( "aria-hidden" ) ) ;
244+ assert . isFalse ( panel . hasAttribute ( "tabindex" ) ) ;
227245 } ) ;
228246 } ) ;
229247
@@ -402,5 +420,22 @@ describe("<pfe-accordion-panel>", () => {
402420 assert . isTrue ( panel . hasAttribute ( 'aria-labelledby' ) ) ;
403421 assert . equal ( panel . getAttribute ( 'role' ) , 'region' ) ;
404422 assert . equal ( panel . id , header . getAttribute ( 'aria-controls' ) ) ;
423+ assert . isFalse ( panel . hasAttribute ( "expanded" ) ) ;
424+ assert . isTrue ( panel . getAttribute ( "aria-hidden" ) == "true" ) ;
425+ assert . isTrue ( panel . getAttribute ( "tabindex" ) == "-1" ) ;
405426 } ) ;
427+
428+ it ( "should add the proper attributes when a panel's expanded property is toggled" , async ( ) => {
429+ const pfeAccordion = await createFixture ( testElement ) ;
430+ const panel = pfeAccordion . querySelector ( "pfe-accordion-panel" ) ;
431+
432+
433+ assert . isFalse ( panel . hasAttribute ( "expanded" ) ) ;
434+ assert . isTrue ( panel . getAttribute ( "aria-hidden" ) == "true" ) ;
435+ assert . isTrue ( panel . getAttribute ( "tabindex" ) == "-1" ) ;
436+
437+ panel . expanded = true ;
438+ assert . isFalse ( panel . hasAttribute ( "aria-hidden" ) ) ;
439+ assert . isFalse ( panel . hasAttribute ( "tabindex" ) ) ;
440+ } )
406441} ) ;
0 commit comments