Skip to content

Commit

Permalink
Handle undefined props like className (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
robmadole authored May 22, 2024
1 parent ffa0bdf commit 47a7be8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,9 @@ jobs:
matrix:
node: [14]
react: [
16.3.x,
16.4.x,
16.5.x,
16.6.x,
16.7.x,
16.8.x,
16.9.x,
16.10.x,
16.11.x,
16.12.x,
17.0.x
16.x,
17.x,
18.x
]
fontawesome-svg-core: [
1.2.x,
Expand Down
2 changes: 1 addition & 1 deletion src/components/FontAwesomeIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const FontAwesomeIcon = React.forwardRef((props, ref) => {

const classes = objectWithKey('classes', [
...classList(allProps),
...className.split(' ')
...(className || '').split(' ')
])
const transform = objectWithKey(
'transform',
Expand Down
36 changes: 36 additions & 0 deletions src/components/__tests__/FontAwesomeIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,42 @@ if (coreHasFeature(REFERENCE_ICON_BY_STYLE)) {
})
}

describe.only('using defaultProps', () => {
const UNDEFINED_DEFAULT_PROPS = {
border: undefined,
className: undefined,
mask: undefined,
maskId: undefined,
fixedWidth: undefined,
inverse: undefined,
flip: undefined,
listItem: undefined,
pull: undefined,
pulse: undefined,
rotation: undefined,
size: undefined,
spin: undefined,
spinPulse: undefined,
spinReverse: undefined,
beat: undefined,
fade: undefined,
beatFade: undefined,
bounce: undefined,
shake: undefined,
symbol: undefined,
title: undefined,
titleId: undefined,
transform: undefined,
swapOpacity: undefined
}

test('undefined props passed', () => {
expect(() =>
mount({ icon: faCoffee, ...UNDEFINED_DEFAULT_PROPS })
).not.toThrow(TypeError)
})
})

test('using imported object from svg icons package', () => {
const vm = mount({
icon: faTimes
Expand Down

0 comments on commit 47a7be8

Please sign in to comment.