mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
fix: Upload onChange immutable (#22322)
* refactor tree dir * Upload onChange immutable * update test case * fix lint
This commit is contained in:
parent
28fea02011
commit
8453cb7b2d
@ -188,7 +188,10 @@ class Upload extends React.Component<UploadProps, UploadState> {
|
||||
|
||||
const { onChange } = this.props;
|
||||
if (onChange) {
|
||||
onChange(info);
|
||||
onChange({
|
||||
...info,
|
||||
fileList: [...info.fileList],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -130,7 +130,9 @@ describe('Upload List', () => {
|
||||
|
||||
it('should be uploading when upload a file', done => {
|
||||
let wrapper;
|
||||
const onChange = ({ file }) => {
|
||||
let latestFileList = null;
|
||||
const onChange = ({ file, fileList: eventFileList }) => {
|
||||
expect(eventFileList === latestFileList).toBeFalsy();
|
||||
if (file.status === 'uploading') {
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
}
|
||||
@ -138,6 +140,8 @@ describe('Upload List', () => {
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
done();
|
||||
}
|
||||
|
||||
latestFileList = eventFileList;
|
||||
};
|
||||
wrapper = mount(
|
||||
<Upload
|
||||
|
Loading…
Reference in New Issue
Block a user