Browse Source

fix: Drapper mulitple should work

pull/18580/merge
zombiej 5 years ago
committed by 偏右
parent
commit
06d7f0deec
  1. 6
      components/upload/Upload.tsx
  2. 24
      components/upload/__tests__/upload.test.js

6
components/upload/Upload.tsx

@ -81,6 +81,12 @@ class Upload extends React.Component<UploadProps, UploadState> {
onStart = (file: RcFile) => {
const { fileList } = this.state;
const { multiple } = this.props;
if (!multiple && fileList.length > 0) {
return;
}
const targetItem = fileToObject(file);
targetItem.status = 'uploading';

24
components/upload/__tests__/upload.test.js

@ -484,4 +484,28 @@ describe('Upload', () => {
);
errorSpy.mockRestore();
});
it('not allow multiple upload when multiple is false', done => {
const onChange = jest.fn();
const wrapper = mount(
<Upload
fileList={[{ uid: '903', file: 'bamboo.png' }]}
action="http://upload.com"
onChange={onChange}
multiple={false}
/>,
);
wrapper.find('input').simulate('change', {
target: {
files: [{ file: 'light.png' }],
},
});
setTimeout(() => {
expect(onChange).not.toHaveBeenCalled();
done();
});
});
});

Loading…
Cancel
Save