@@ -213,4 +213,40 @@ describe('<md-branded-fab>', () => {
213213 expect ( button . classList . contains ( 'large' ) ) . toBeFalse ( ) ;
214214 } ) ;
215215 } ) ;
216+
217+ describe ( 'accessibility' , ( ) => {
218+ it ( 'sets aria-hidden on the icon slot when aria-label is set' , async ( ) => {
219+ const { button, harness} = await setupTest ( ) ;
220+ await env . waitForStability ( ) ;
221+
222+ const iconSlot = button . querySelector ( 'slot[name="icon"]' ) ! ;
223+
224+ expect ( button . hasAttribute ( 'aria-label' ) ) . toBeFalse ( ) ;
225+ expect ( iconSlot . hasAttribute ( 'aria-hidden' ) ) . toBeFalse ( ) ;
226+
227+ const element = harness . element ;
228+ element . ariaLabel = 'foo' ;
229+ await env . waitForStability ( ) ;
230+
231+ expect ( button . hasAttribute ( 'aria-label' ) ) . toBeTrue ( ) ;
232+ expect ( iconSlot . getAttribute ( 'aria-hidden' ) ) . toEqual ( 'true' ) ;
233+ } ) ;
234+
235+ it ( 'sets aria-hidden on the icon slot when label is set' , async ( ) => {
236+ const { button, harness} = await setupTest ( ) ;
237+ await env . waitForStability ( ) ;
238+ const element = harness . element ;
239+
240+ const iconSlot = button . querySelector ( 'slot[name="icon"]' ) ! ;
241+
242+ expect ( ! ! element . label ) . toBeFalse ( ) ;
243+ expect ( iconSlot . hasAttribute ( 'aria-hidden' ) ) . toBeFalse ( ) ;
244+
245+ element . label = 'foo' ;
246+ await env . waitForStability ( ) ;
247+
248+ expect ( ! ! element . label ) . toBeTrue ( ) ;
249+ expect ( iconSlot . getAttribute ( 'aria-hidden' ) ) . toEqual ( 'true' ) ;
250+ } ) ;
251+ } ) ;
216252} ) ;
0 commit comments