Browse Source

Fix: Print reject error when ActionButton catch promise rejects

pull/16437/head
Jason 6 years ago
parent
commit
db5da92f0c
  1. 4
      components/modal/ActionButton.tsx
  2. 13
      components/modal/__tests__/confirm.test.js

4
components/modal/ActionButton.tsx

@ -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 });
},

13
components/modal/__tests__/confirm.test.js

@ -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…
Cancel
Save