fix(uploader): automatically filter files exceeding the max-size (#6150)
This commit is contained in:
@@ -84,6 +84,14 @@ exports[`renders demo correctly 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="van-uploader">
|
||||
<div class="van-uploader__wrapper">
|
||||
<div class="van-uploader__upload"><i class="van-icon van-icon-photograph van-uploader__upload-icon">
|
||||
<!----></i><input multiple="multiple" type="file" accept="image/*" class="van-uploader__input"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="van-uploader">
|
||||
<div class="van-uploader__wrapper">
|
||||
|
||||
@@ -487,3 +487,23 @@ test('file message should be reactive', (done) => {
|
||||
|
||||
wrapper.vm.onChange(file);
|
||||
});
|
||||
|
||||
test('multiFile upload filter max-size file', async () => {
|
||||
const SmallFile = function () {
|
||||
this.size = 100;
|
||||
};
|
||||
const multiFiles = {
|
||||
target: { files: [mockFile, new SmallFile([], 'small-test.jpg')] },
|
||||
};
|
||||
|
||||
const wrapper = mount(Uploader, {
|
||||
propsData: {
|
||||
maxSize: 1000,
|
||||
},
|
||||
});
|
||||
wrapper.vm.onChange(multiFiles);
|
||||
|
||||
await later();
|
||||
|
||||
expect(wrapper.emitted('oversize')[0]).toBeTruthy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user