fix(uploader): automatically filter files exceeding the max-size (#6150)

This commit is contained in:
fujialing
2020-04-27 21:01:35 +08:00
committed by GitHub
parent 9e7d72eff2
commit 8aced05260
6 changed files with 117 additions and 5 deletions
@@ -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">
+20
View File
@@ -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();
});