Skip to content

Commit

Permalink
Adding titleId (#489)
Browse files Browse the repository at this point in the history
robmadole authored Feb 24, 2022
1 parent 797dd75 commit ac63cd4
Showing 6 changed files with 20 additions and 9 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -36,10 +36,8 @@ jobs:
npm install react@${{ matrix.react }} react-dom@${{ matrix.react }} react-test-renderer@${{ matrix.react }}
npm list react react-dom react-test-renderer
npm run lint
npm run test.latest
npm run test.next.proregistry
env:
FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}
npm run test.5
npm run test.6
- name: dist
run: |
npm run dist
2 changes: 0 additions & 2 deletions .npmrc.proregistry

This file was deleted.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -46,5 +46,6 @@ export interface FontAwesomeIconProps extends BackwardCompatibleOmit<SVGAttribut
style?: CSSProperties
tabIndex?: number;
title?: string;
titleId?: string;
swapOpacity?: boolean;
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -34,9 +34,9 @@
"lint": "eslint src",
"prettier": "pretty-quick --pattern src/** --staged",
"prepack": "npm run dist",
"test": "npm run test.latest && npm run test.next.proregistry",
"test.latest": "npm --no-save install @fortawesome/fontawesome-svg-core@latest @fortawesome/free-solid-svg-icons@latest && jest --silent",
"test.next.proregistry": "npm --userconfig .npmrc.proregistry --registry https://npm.fontawesome.com install --no-save @fortawesome/fontawesome-svg-core@next @fortawesome/free-solid-svg-icons@next && jest --silent",
"test": "npm run test.5 && npm run test.6",
"test.5": "npm --no-save install @fortawesome/fontawesome-svg-core@1.2.x @fortawesome/free-solid-svg-icons@5.x && jest --silent",
"test.6": "npm --no-save install @fortawesome/fontawesome-svg-core@1.3.x @fortawesome/free-solid-svg-icons@6.x && jest --silent",
"clean": "rm -f index.js && rm -f index.es.js"
},
"lint-staged": {
3 changes: 3 additions & 0 deletions src/components/FontAwesomeIcon.js
Original file line number Diff line number Diff line change
@@ -130,6 +130,8 @@ FontAwesomeIcon.propTypes = {

title: PropTypes.string,

titleId: PropTypes.string,

transform: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),

swapOpacity: PropTypes.bool
@@ -156,6 +158,7 @@ FontAwesomeIcon.defaultProps = {
shake: false,
symbol: false,
title: '',
titleId: null,
transform: null,
swapOpacity: false
}
11 changes: 11 additions & 0 deletions src/components/__tests__/FontAwesomeIcon.test.js
Original file line number Diff line number Diff line change
@@ -354,14 +354,25 @@ describe('symbol', () => {
describe('title', () => {
test('will not add a title element', () => {
const vm = mount({ icon: faCoffee })

expect(vm.children[0].type).not.toBe('title')
})

test('will add a title element', () => {
const vm = mount({ icon: faCoffee, title: 'Coffee' })

expect(vm.children[0].type).toBe('title')
expect(vm.children[0].children[0]).toBe('Coffee')
})

test.only('will use an explicit titleId', () => {

This comment has been minimized.

Copy link
@mzedeler

mzedeler Jul 12, 2022

This looks like something that will disable the other tests?

const vm = mount({ icon: faCoffee, title: 'Coffee', titleId: 'coffee-title' })

expect(vm.props['aria-labelledby']).toBe('svg-inline--fa-title-coffee-title')
expect(vm.children[0].props).toEqual(
expect.objectContaining({ id: 'svg-inline--fa-title-coffee-title' })
)
})
})

describe('swap opacity', () => {

0 comments on commit ac63cd4

Please sign in to comment.