mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
Fix: Print reject error when ActionButton catch promise rejects
This commit is contained in:
parent
6d845f60ef
commit
db5da92f0c
@ -56,7 +56,9 @@ export default class ActionButton extends React.Component<ActionButtonProps, Act
|
||||
// this.setState({ loading: false });
|
||||
closeModal(...args);
|
||||
},
|
||||
() => {
|
||||
(e: Error) => {
|
||||
// Emit error when catch promise reject
|
||||
console.error(e);
|
||||
// See: https://github.com/ant-design/ant-design/issues/6183
|
||||
this.setState({ loading: false });
|
||||
},
|
||||
|
@ -67,6 +67,19 @@ describe('Modal.confirm triggers callbacks correctly', () => {
|
||||
expect(errorSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit error when onOk return Promise.reject', () => {
|
||||
const error = new Error('something wrong');
|
||||
open({
|
||||
onOk: () => Promise.reject(error),
|
||||
});
|
||||
// Fifth Modal
|
||||
$$('.ant-btn-primary')[0].click();
|
||||
// wait promise
|
||||
return Promise.resolve().then(() => {
|
||||
expect(errorSpy).toHaveBeenCalledWith(error);
|
||||
});
|
||||
});
|
||||
|
||||
if (process.env.REACT !== '15') {
|
||||
it('shows animation when close', () => {
|
||||
jest.useFakeTimers();
|
||||
|
Loading…
Reference in New Issue
Block a user