mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
add test case
This commit is contained in:
parent
4ac517d610
commit
7c5083f4fa
@ -319,4 +319,53 @@ describe('Upload', () => {
|
||||
expect(linkNode.props().download).toBe('image');
|
||||
expect(linkNode.props().rel).toBe('noopener');
|
||||
});
|
||||
|
||||
it('should not stop remove when return value of onRemove is false', () => {
|
||||
const mockRemove = jest.fn(() => false);
|
||||
const props = {
|
||||
onRemove: mockRemove,
|
||||
fileList: [
|
||||
{
|
||||
uid: '-1',
|
||||
name: 'foo.png',
|
||||
status: 'done',
|
||||
url: 'http://www.baidu.com/xxx.png',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const wrapper = mount(<Upload {...props} />);
|
||||
|
||||
wrapper.find('div.ant-upload-list-item i.anticon-close').simulate('click');
|
||||
|
||||
expect(mockRemove).toBeCalled();
|
||||
expect(props.fileList).toHaveLength(1);
|
||||
expect(props.fileList[0].status).toBe('done');
|
||||
});
|
||||
|
||||
it('remove file in onRemove', done => {
|
||||
const mockRemove = jest.fn();
|
||||
const props = {
|
||||
onRemove: mockRemove,
|
||||
fileList: [
|
||||
{
|
||||
uid: '-1',
|
||||
name: 'foo.png',
|
||||
status: 'done',
|
||||
url: 'http://www.baidu.com/xxx.png',
|
||||
},
|
||||
],
|
||||
onChange: ({ file }, fileList) => {
|
||||
if (file.status === 'removed') {
|
||||
expect(mockRemove).toBeCalled();
|
||||
expect(fileList).toHaveLength(0);
|
||||
done();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const wrapper = mount(<Upload {...props} />);
|
||||
|
||||
wrapper.find('div.ant-upload-list-item i.anticon-close').simulate('click');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user