mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
fix autoUpdateProgress percent and add test case
This commit is contained in:
parent
77301c378f
commit
89ed0dcb35
@ -79,7 +79,7 @@ export default class Upload extends React.Component<UploadProps, UploadState> {
|
||||
this.progressTimer = setInterval(() => {
|
||||
curPercent = getPercent(curPercent);
|
||||
this.onProgress({
|
||||
percent: curPercent,
|
||||
percent: curPercent * 100,
|
||||
}, file);
|
||||
}, 200);
|
||||
}
|
||||
|
@ -86,6 +86,43 @@ describe('Upload', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should increase percent automaticly when call autoUpdateProgress in IE', (done) => {
|
||||
let uploadInstance;
|
||||
let lastPercent = -1;
|
||||
const props = {
|
||||
action: 'http://jsonplaceholder.typicode.com/posts/',
|
||||
onChange: ({ file }) => {
|
||||
if (file.percent === 0 && file.status === 'uploading') {
|
||||
// manually call it
|
||||
uploadInstance.autoUpdateProgress(0, file);
|
||||
}
|
||||
if (file.status === 'uploading') {
|
||||
expect(file.percent).toBeGreaterThan(lastPercent);
|
||||
lastPercent = file.percent;
|
||||
}
|
||||
if (file.status === 'done' || file.status === 'error') {
|
||||
done();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const wrapper = mount(
|
||||
<Upload {...props}>
|
||||
<button>upload</button>
|
||||
</Upload>
|
||||
);
|
||||
|
||||
wrapper.find('input').simulate('change', {
|
||||
target: {
|
||||
files: [
|
||||
{ file: 'foo.png' },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
uploadInstance = wrapper.instance();
|
||||
});
|
||||
|
||||
it('should not stop upload when return value of beforeUpload is not false', (done) => {
|
||||
const data = jest.fn();
|
||||
const props = {
|
||||
|
@ -39,7 +39,7 @@ export function genPercentAdd() {
|
||||
if (k < 0.001) {
|
||||
k = 0.001;
|
||||
}
|
||||
return start * 100;
|
||||
return start;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user