mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-19 12:04:02 +08:00
add upload limit & form validate return promise (#7405)
* Carbon: upload limit & input append & form validate promise * Update upload.md * Update upload.md * Update index.js
This commit is contained in:
@@ -101,6 +101,13 @@ describe('Upload', () => {
|
||||
if (handlers.onPreview) {
|
||||
handlers.onPreview(file);
|
||||
}
|
||||
},
|
||||
limit: 2,
|
||||
onExceed(files, fileList) {
|
||||
console.log('onExceed', files, fileList);
|
||||
if (handlers.onExceed) {
|
||||
handlers.onExceed(files, fileList);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -223,5 +230,31 @@ describe('Upload', () => {
|
||||
requests[0].respond(200, {}, `${files[0].name}`);
|
||||
}, 100);
|
||||
});
|
||||
|
||||
it('limit files', done => {
|
||||
const files = [{
|
||||
name: 'exceed2.png',
|
||||
type: 'xml'
|
||||
}, {
|
||||
name: 'exceed3.png',
|
||||
type: 'xml'
|
||||
}];
|
||||
|
||||
uploader.uploadFiles = [{
|
||||
name: 'exceed1.png',
|
||||
type: 'xml'
|
||||
}];
|
||||
|
||||
handlers.onExceed = (files, fileList) => {
|
||||
uploader.$nextTick(_ => {
|
||||
expect(uploader.uploadFiles.length).to.equal(1);
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
console.log(uploader.$refs['upload-inner'].limit, uploader.$refs['upload-inner'].fileList, uploader.$refs['upload-inner'].onExceed);
|
||||
|
||||
uploader.$nextTick(_ => uploader.$refs['upload-inner'].handleChange({ target: { files }}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user