@@ -6,14 +6,14 @@ import { faTimes } from '@fortawesome/free-solid-svg-icons'
66import { faCoffee , faCircle , faSpartan } from '../__fixtures__/icons'
77import {
88 ICON_PACKS_STARTING_VERSION ,
9- SVG_CORE_VERSION ,
9+ SVG_CORE_VERSION
1010} from '../../utils/get-class-list-from-props'
1111import {
1212 coreHasFeature ,
1313 REFERENCE_ICON_USING_STRING ,
1414 REFERENCE_ICON_BY_STYLE ,
1515 ICON_ALIASES ,
16- mount ,
16+ mount
1717} from '../__fixtures__/helpers'
1818
1919jest . mock ( '../../logger' )
@@ -28,7 +28,7 @@ afterEach(() => {
2828
2929test ( 'using a FAT icon using array format' , ( ) => {
3030 const vm = mount ( {
31- icon : [ 'fat' , 'spartan' ] ,
31+ icon : [ 'fat' , 'spartan' ]
3232 } )
3333
3434 expect ( vm . type ) . toBe ( 'svg' )
@@ -111,7 +111,7 @@ describe('using defaultProps', () => {
111111 title : undefined ,
112112 titleId : undefined ,
113113 transform : undefined ,
114- swapOpacity : undefined ,
114+ swapOpacity : undefined
115115 }
116116
117117 test ( 'undefined props passed' , ( ) => {
@@ -123,7 +123,7 @@ describe('using defaultProps', () => {
123123
124124test ( 'using imported object from svg icons package' , ( ) => {
125125 const vm = mount ( {
126- icon : faTimes ,
126+ icon : faTimes
127127 } )
128128
129129 expect ( vm . type ) . toBe ( 'svg' )
@@ -132,7 +132,7 @@ test('using imported object from svg icons package', () => {
132132test ( 'using pack and name' , ( ) => {
133133 const vm = mount ( {
134134 icon : [ 'fas' , 'coffee' ] ,
135- style : { backgroundColor : 'white' } ,
135+ style : { backgroundColor : 'white' }
136136 } )
137137
138138 expect ( vm . type ) . toBe ( 'svg' )
@@ -281,7 +281,7 @@ test('using size', () => {
281281 '7x' ,
282282 '8x' ,
283283 '9x' ,
284- '10x' ,
284+ '10x'
285285 ] . forEach ( ( size ) => {
286286 const vm = mount ( { icon : faCoffee , size : size } )
287287
@@ -411,12 +411,12 @@ describe('using transform', () => {
411411 const vm = mount ( {
412412 icon : faCoffee ,
413413 transform : 'grow-40 left-4 rotate-15' ,
414- style : { backgroundColor : 'white' } ,
414+ style : { backgroundColor : 'white' }
415415 } )
416416
417417 expect ( vm . props . style ) . toEqual ( {
418418 backgroundColor : 'white' ,
419- transformOrigin : '0.375em 0.5em' ,
419+ transformOrigin : '0.375em 0.5em'
420420 } )
421421 } )
422422
@@ -429,8 +429,8 @@ describe('using transform', () => {
429429 rotate : 15 ,
430430 size : 56 ,
431431 x : - 4 ,
432- y : 0 ,
433- } ,
432+ y : 0
433+ }
434434 } )
435435
436436 expect ( vm . props . style ) . toEqual ( { transformOrigin : '0.375em 0.5em' } )
@@ -475,35 +475,37 @@ describe('symbol', () => {
475475 } )
476476} )
477477
478- describe ( 'title' , ( ) => {
479- test ( 'will not add a title element' , ( ) => {
480- const vm = mount ( { icon : faCoffee } )
478+ if ( semver . lt ( SVG_CORE_VERSION , ICON_PACKS_STARTING_VERSION ) ) {
479+ describe ( 'title' , ( ) => {
480+ test ( 'will not add a title element' , ( ) => {
481+ const vm = mount ( { icon : faCoffee } )
481482
482- expect ( vm . children [ 0 ] . type ) . not . toBe ( 'title' )
483- } )
483+ expect ( vm . children [ 0 ] . type ) . not . toBe ( 'title' )
484+ } )
484485
485- test ( 'will add a title element' , ( ) => {
486- const vm = mount ( { icon : faCoffee , title : 'Coffee' } )
486+ test ( 'will add a title element' , ( ) => {
487+ const vm = mount ( { icon : faCoffee , title : 'Coffee' } )
487488
488- expect ( vm . children [ 0 ] . type ) . toBe ( 'title' )
489- expect ( vm . children [ 0 ] . children [ 0 ] ) . toBe ( 'Coffee' )
490- } )
491-
492- test ( 'will use an explicit titleId' , ( ) => {
493- const vm = mount ( {
494- icon : faCoffee ,
495- title : 'Coffee' ,
496- titleId : 'coffee-title' ,
489+ expect ( vm . children [ 0 ] . type ) . toBe ( 'title' )
490+ expect ( vm . children [ 0 ] . children [ 0 ] ) . toBe ( 'Coffee' )
497491 } )
498492
499- expect ( vm . props [ 'aria-labelledby' ] ) . toBe (
500- 'svg-inline--fa-title-coffee-title'
501- )
502- expect ( vm . children [ 0 ] . props ) . toEqual (
503- expect . objectContaining ( { id : 'svg-inline--fa-title-coffee-title' } )
504- )
493+ test ( 'will use an explicit titleId' , ( ) => {
494+ const vm = mount ( {
495+ icon : faCoffee ,
496+ title : 'Coffee' ,
497+ titleId : 'coffee-title'
498+ } )
499+
500+ expect ( vm . props [ 'aria-labelledby' ] ) . toBe (
501+ 'svg-inline--fa-title-coffee-title'
502+ )
503+ expect ( vm . children [ 0 ] . props ) . toEqual (
504+ expect . objectContaining ( { id : 'svg-inline--fa-title-coffee-title' } )
505+ )
506+ } )
505507 } )
506- } )
508+ }
507509
508510describe ( 'swap opacity' , ( ) => {
509511 test ( 'setting swapOpacity prop to true adds fa-swap-opacity class' , ( ) => {
@@ -529,7 +531,7 @@ describe('using ref', () => {
529531 mount (
530532 { icon : faCoffee , ref : spy } ,
531533 {
532- createNodeMock : ( ) => node ,
534+ createNodeMock : ( ) => node
533535 }
534536 )
535537
@@ -544,19 +546,21 @@ describe('using ref', () => {
544546 mount (
545547 { icon : faCoffee , ref : setForwardedRef } ,
546548 {
547- createNodeMock : ( ) => node ,
549+ createNodeMock : ( ) => node
548550 }
549551 )
550552
551553 expect ( forwardedRef ) . toBe ( node )
552554 } )
553555} )
554556
555- describe ( 'using titleId' , ( ) => {
556- test ( 'setting titleId prop reflects in the aria-labelledby attribute' , ( ) => {
557- const titleId = 'foo'
558- const vm = mount ( { icon : faCoffee , titleId : titleId , title : 'Coffee' } )
559- const ariaLabelledby = vm . props [ 'aria-labelledby' ]
560- expect ( ariaLabelledby . includes ( titleId ) ) . toBeTruthy ( )
557+ if ( semver . lt ( SVG_CORE_VERSION , ICON_PACKS_STARTING_VERSION ) ) {
558+ describe ( 'using titleId' , ( ) => {
559+ test ( 'setting titleId prop reflects in the aria-labelledby attribute' , ( ) => {
560+ const titleId = 'foo'
561+ const vm = mount ( { icon : faCoffee , titleId : titleId , title : 'Coffee' } )
562+ const ariaLabelledby = vm . props [ 'aria-labelledby' ]
563+ expect ( ariaLabelledby . includes ( titleId ) ) . toBeTruthy ( )
564+ } )
561565 } )
562- } )
566+ }
0 commit comments