mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
fix(upload): file
in fileList
should get uid
at first (#30087)
* docs: delete info log in tree examples * fix: make check-ts-demo work * fix(upload): fileList should add uid at first * revert(docs): revert delete log(info) * style: delete unused test utils
This commit is contained in:
parent
bbbb7f573c
commit
e4e5cc66e9
@ -73,7 +73,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
|
||||
}, []);
|
||||
|
||||
// Control mode will auto fill file uid if not provided
|
||||
React.useEffect(() => {
|
||||
React.useMemo(() => {
|
||||
const timestamp = Date.now();
|
||||
|
||||
(fileList || []).forEach((file, index) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable react/no-string-refs, react/prefer-es6-class */
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { mount, render } from 'enzyme';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import produce from 'immer';
|
||||
import { cloneDeep } from 'lodash';
|
||||
@ -285,6 +285,20 @@ describe('Upload', () => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('should be able to get uid at first', () => {
|
||||
const fileList = [
|
||||
{
|
||||
name: 'foo.png',
|
||||
status: 'done',
|
||||
url: 'http://www.baidu.com/xxx.png',
|
||||
},
|
||||
];
|
||||
render(<Upload fileList={fileList} />);
|
||||
fileList.forEach(file => {
|
||||
expect(file.uid).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('util', () => {
|
||||
it('should be able to get fileItem', () => {
|
||||
const file = { uid: '-1', name: 'item.jpg' };
|
||||
|
Loading…
Reference in New Issue
Block a user