88 REFERENCE_ICON_USING_STRING ,
99 REFERENCE_ICON_BY_STYLE ,
1010 ICON_ALIASES ,
11+ USES_A11Y_TITLE ,
1112 mount
1213} from '../__fixtures__/helpers'
1314
@@ -426,36 +427,6 @@ describe('symbol', () => {
426427 } )
427428} )
428429
429- describe ( 'title' , ( ) => {
430- test ( 'will not add a title element' , ( ) => {
431- const vm = mount ( { icon : faCoffee } )
432-
433- expect ( vm . children [ 0 ] . type ) . not . toBe ( 'title' )
434- } )
435-
436- test ( 'will add a title element' , ( ) => {
437- const vm = mount ( { icon : faCoffee , title : 'Coffee' } )
438-
439- expect ( vm . children [ 0 ] . type ) . toBe ( 'title' )
440- expect ( vm . children [ 0 ] . children [ 0 ] ) . toBe ( 'Coffee' )
441- } )
442-
443- test ( 'will use an explicit titleId' , ( ) => {
444- const vm = mount ( {
445- icon : faCoffee ,
446- title : 'Coffee' ,
447- titleId : 'coffee-title'
448- } )
449-
450- expect ( vm . props [ 'aria-labelledby' ] ) . toBe (
451- 'svg-inline--fa-title-coffee-title'
452- )
453- expect ( vm . children [ 0 ] . props ) . toEqual (
454- expect . objectContaining ( { id : 'svg-inline--fa-title-coffee-title' } )
455- )
456- } )
457- } )
458-
459430describe ( 'swap opacity' , ( ) => {
460431 test ( 'setting swapOpacity prop to true adds fa-swap-opacity class' , ( ) => {
461432 const vm = mount ( { icon : faCoffee , swapOpacity : true } )
@@ -471,11 +442,43 @@ describe('swap opacity', () => {
471442 } )
472443} )
473444
474- describe ( 'using titleId' , ( ) => {
475- test ( 'setting titleId prop reflects in the aria-labelledby attribute' , ( ) => {
476- const titleId = 'foo'
477- const vm = mount ( { icon : faCoffee , titleId, title : 'Coffee' } )
478- const ariaLabelledby = vm . props [ 'aria-labelledby' ]
479- expect ( ariaLabelledby . includes ( titleId ) ) . toBeTruthy ( )
445+ if ( coreHasFeature ( USES_A11Y_TITLE ) ) {
446+ describe ( 'title' , ( ) => {
447+ test ( 'will not add a title element' , ( ) => {
448+ const vm = mount ( { icon : faCoffee } )
449+
450+ expect ( vm . children [ 0 ] . type ) . not . toBe ( 'title' )
451+ } )
452+
453+ test ( 'will add a title element' , ( ) => {
454+ const vm = mount ( { icon : faCoffee , title : 'Coffee' } )
455+
456+ expect ( vm . children [ 0 ] . type ) . toBe ( 'title' )
457+ expect ( vm . children [ 0 ] . children [ 0 ] ) . toBe ( 'Coffee' )
458+ } )
459+
460+ test ( 'will use an explicit titleId' , ( ) => {
461+ const vm = mount ( {
462+ icon : faCoffee ,
463+ title : 'Coffee' ,
464+ titleId : 'coffee-title'
465+ } )
466+
467+ expect ( vm . props [ 'aria-labelledby' ] ) . toBe (
468+ 'svg-inline--fa-title-coffee-title'
469+ )
470+ expect ( vm . children [ 0 ] . props ) . toEqual (
471+ expect . objectContaining ( { id : 'svg-inline--fa-title-coffee-title' } )
472+ )
473+ } )
480474 } )
481- } )
475+
476+ describe ( 'using titleId' , ( ) => {
477+ test ( 'setting titleId prop reflects in the aria-labelledby attribute' , ( ) => {
478+ const titleId = 'foo'
479+ const vm = mount ( { icon : faCoffee , titleId, title : 'Coffee' } )
480+ const ariaLabelledby = vm . props [ 'aria-labelledby' ]
481+ expect ( ariaLabelledby . includes ( titleId ) ) . toBeTruthy ( )
482+ } )
483+ } )
484+ }
0 commit comments