Skip to content

Commit

Permalink
fix(community-toggle-switch): makes spinnerLabel prop optional
Browse files Browse the repository at this point in the history
ToggleSwitch required spinnerLabel, yet isLoading prop is optional. spinnerLabel is only needed in cases where isLoading prop is passed.

Fixes issue 311
  • Loading branch information
fzero authored and mike-bunce committed Jan 31, 2020
1 parent dca3d4d commit ee04d07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/ToggleSwitch/ToggleSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ToggleSwitch.propTypes = {
tooltipCopy: PropTypes.string,

/** Communicates a message to assistive technology while spinner is visible. */
spinnerLabel: PropTypes.string.isRequired,
spinnerLabel: PropTypes.string,

/** A callback function to be invoked when the ToggleSwitch button is clicked on.
@param {SyntheticEvent} event The React `SyntheticEvent` */
Expand All @@ -127,6 +127,7 @@ ToggleSwitch.defaultProps = {
checked: false,
tooltipText: undefined,
tooltipCopy: undefined,
spinnerLabel: undefined,
isLoading: false,
}

Expand Down
6 changes: 4 additions & 2 deletions packages/ToggleSwitch/__tests__/ToggleSwitch.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('ToggleSwitch', () => {
name: 'name',
value: 'value',
toolTipCopy: 'en',
spinnerLabel: 'Request is processing.',
onClick: mockOnClick,
}

Expand Down Expand Up @@ -150,7 +149,10 @@ describe('ToggleSwitch', () => {
})

it('show spinner when isLoading=true', () => {
const toggleSwitch = doShallow({ isLoading: true })
const toggleSwitch = doShallow({
isLoading: true,
spinnerLabel: 'Request is processing.',
})
const spinner = toggleSwitch.find('Spinner')
expect(spinner.prop('spinning')).toEqual(true)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ exports[`ToggleSwitch renders 1`] = `
label="label"
name="name"
onClick={[MockFunction]}
spinnerLabel="Request is processing."
toolTipCopy="en"
value="value"
>
Expand Down Expand Up @@ -170,7 +169,6 @@ exports[`ToggleSwitch renders 1`] = `
dangerouslyHideVisibleLabel={false}
fullScreen={false}
inline={true}
label="Request is processing."
size="small"
spinning={false}
tag="span"
Expand Down

0 comments on commit ee04d07

Please sign in to comment.