Progressable button text is kept if in progress but no progress value is set
This commit is contained in:
parent
1d4254fd3d
commit
314e450cb8
3 changed files with 34 additions and 1 deletions
|
@ -25,6 +25,17 @@ describe('ProgressableButton', () => {
|
||||||
expect(toJson(output)).toMatchSnapshot()
|
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', () => {
|
test('Progress means we change the title, disable and do turn on spinner', () => {
|
||||||
let output = mount(
|
let output = mount(
|
||||||
<ProgressableButton onClick={() => console.log('alert!')}
|
<ProgressableButton onClick={() => console.log('alert!')}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ProgressableButton extends React.Component<ProgressableButtonProps, {}> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.inProgress){
|
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.disabled = ourData.disabled || this.props.disableOnProgress
|
||||||
ourData.prefix = <i className='fa fa-spin fa-spinner'></i>
|
ourData.prefix = <i className='fa fa-spin fa-spinner'></i>
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,3 +110,25 @@ exports[`ProgressableButton Progress means we change the title, dont disable and
|
||||||
</button>
|
</button>
|
||||||
</ProgressableButton>
|
</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>
|
||||||
|
`;
|
||||||
|
|
Loading…
Reference in a new issue