Progressable button text is kept if in progress but no progress value is set

This commit is contained in:
Eric Schultz 2018-06-27 16:37:12 -05:00
parent 1d4254fd3d
commit 314e450cb8
3 changed files with 34 additions and 1 deletions

View file

@ -25,6 +25,17 @@ describe('ProgressableButton', () => {
expect(toJson(output)).toMatchSnapshot()
})
test('Title is kept on progress if no titleOnProgress is set', () => {
let output = mount(
<ProgressableButton onClick={() => console.log('alert!')}
title={"nothing"}
data-label="button"
inProgress={true}
/>)
expect(toJson(output)).toMatchSnapshot()
})
test('Progress means we change the title, disable and do turn on spinner', () => {
let output = mount(
<ProgressableButton onClick={() => console.log('alert!')}

View file

@ -24,7 +24,7 @@ class ProgressableButton extends React.Component<ProgressableButtonProps, {}> {
}
if (this.props.inProgress){
ourData.title = this.props.titleOnProgress
ourData.title = this.props.titleOnProgress || this.props.title
ourData.disabled = ourData.disabled || this.props.disableOnProgress
ourData.prefix = <i className='fa fa-spin fa-spinner'></i>
}

View file

@ -110,3 +110,25 @@ exports[`ProgressableButton Progress means we change the title, dont disable and
</button>
</ProgressableButton>
`;
exports[`ProgressableButton Title is kept on progress if no titleOnProgress is set 1`] = `
<ProgressableButton
data-label="button"
inProgress={true}
onClick={[Function]}
title="nothing"
>
<button
className="button"
data-label="button"
onClick={[Function]}
>
<span>
<i
className="fa fa-spin fa-spinner"
/>
nothing
</span>
</button>
</ProgressableButton>
`;