From 4db2ca6cd6e3d6a40dd4f78fbb35e3d7fa959386 Mon Sep 17 00:00:00 2001 From: Gavin <19986739+wjw-gavin@users.noreply.github.com> Date: Fri, 4 Nov 2022 15:15:46 +0800 Subject: [PATCH] fix(Uploader): chooseFile is invalid when show-upload = false (#11221) --- src/uploader/index.js | 3 ++- src/uploader/test/index.spec.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/uploader/index.js b/src/uploader/index.js index baa2d9821..3a540e796 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -404,7 +404,7 @@ export default createComponent({ }, genUpload() { - if (this.fileList.length >= this.maxCount || !this.showUpload) { + if (this.fileList.length >= this.maxCount) { return; } @@ -446,6 +446,7 @@ export default createComponent({ return (
{ test('show-upload prop', () => { const wrapper = mount(Uploader); - expect(wrapper.contains('.van-uploader__upload')).toBeTruthy(); + + const upload = wrapper.find('.van-uploader__upload'); + expect(upload.element).toBeTruthy(); wrapper.setProps({ showUpload: false }); - expect(wrapper.contains('.van-uploader__upload')).toBeFalsy(); + expect(upload.element.style.display).toBe('none'); }); test('file message should be reactive', (done) => {