From c1a0d3059f18d92ebd3343151adc49bb985318b9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 20 Feb 2020 22:47:14 +0800 Subject: [PATCH] :lipstick: tweak Upload showDownloadIcon default value it should be false --- components/upload/UploadList.tsx | 2 +- .../__tests__/__snapshots__/demo.test.js.snap | 227 +----------- .../__snapshots__/uploadlist.test.js.snap | 327 +----------------- components/upload/__tests__/upload.test.js | 3 + .../upload/__tests__/uploadlist.test.js | 29 +- components/upload/demo/defaultFileList.md | 3 + components/upload/style/index.less | 3 +- 7 files changed, 53 insertions(+), 541 deletions(-) diff --git a/components/upload/UploadList.tsx b/components/upload/UploadList.tsx index 7cfddc5e06f6..5925c17d92ef 100644 --- a/components/upload/UploadList.tsx +++ b/components/upload/UploadList.tsx @@ -16,7 +16,7 @@ export default class UploadList extends React.Component { showInfo: false, }, showRemoveIcon: true, - showDownloadIcon: true, + showDownloadIcon: false, showPreviewIcon: true, previewFile: previewImage, }; diff --git a/components/upload/__tests__/__snapshots__/demo.test.js.snap b/components/upload/__tests__/__snapshots__/demo.test.js.snap index 944307fb7a89..c01a9e8c4a73 100644 --- a/components/upload/__tests__/__snapshots__/demo.test.js.snap +++ b/components/upload/__tests__/__snapshots__/demo.test.js.snap @@ -64,7 +64,7 @@ exports[`renders ./components/upload/demo/defaultFileList.md correctly 1`] = ` - - - - - @@ -162,7 +137,7 @@ exports[`renders ./components/upload/demo/defaultFileList.md correctly 1`] = ` - - - - - @@ -369,7 +319,7 @@ exports[`renders ./components/upload/demo/fileList.md correctly 1`] = ` - - - - - @@ -474,7 +399,7 @@ exports[`renders ./components/upload/demo/picture-card.md correctly 1`] = ` /> - - - - - - - - - - - - - - - - - @@ -1225,7 +1041,7 @@ exports[`renders ./components/upload/demo/picture-style.md correctly 1`] = ` /> - - - - - diff --git a/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap b/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap index 38e067dbfe2c..c0261a3e6f53 100644 --- a/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap +++ b/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap @@ -280,7 +280,7 @@ exports[`Upload List should be uploading when upload a file 2`] = ` foo.png @@ -288,31 +288,6 @@ exports[`Upload List should be uploading when upload a file 2`] = ` - - - - - @@ -440,7 +415,7 @@ exports[`Upload List should non-image format file preview 1`] = ` - - - - - @@ -531,7 +481,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -641,7 +566,7 @@ exports[`Upload List should non-image format file preview 1`] = ` - - - - - @@ -751,7 +651,7 @@ exports[`Upload List should non-image format file preview 1`] = ` - - - - - @@ -842,7 +717,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -933,7 +783,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -1024,7 +849,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -1115,7 +915,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -1206,7 +981,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -1297,7 +1047,7 @@ exports[`Upload List should non-image format file preview 1`] = ` /> - - - - - @@ -1462,7 +1187,7 @@ exports[`Upload List should support showRemoveIcon and showPreviewIcon 1`] = ` /> - - - - - - + /> diff --git a/components/upload/__tests__/upload.test.js b/components/upload/__tests__/upload.test.js index eb71925a1f02..1743cec39337 100644 --- a/components/upload/__tests__/upload.test.js +++ b/components/upload/__tests__/upload.test.js @@ -523,6 +523,9 @@ describe('Upload', () => { const mockRemove = jest.fn(() => false); const props = { onRemove: mockRemove, + showUploadList: { + showDownloadIcon: true, + }, fileList: [ { uid: '-1', diff --git a/components/upload/__tests__/uploadlist.test.js b/components/upload/__tests__/uploadlist.test.js index 6f104994529f..9eb5d1402ce4 100644 --- a/components/upload/__tests__/uploadlist.test.js +++ b/components/upload/__tests__/uploadlist.test.js @@ -205,7 +205,7 @@ describe('Upload List', () => { it('In the case of listType=picture, the error status does not show the download.', () => { const file = { status: 'error', uid: 'file' }; const wrapper = mount( - + , ); @@ -215,7 +215,7 @@ describe('Upload List', () => { it('In the case of listType=picture-card, the error status does not show the download.', () => { const file = { status: 'error', uid: 'file' }; const wrapper = mount( - + , ); @@ -225,7 +225,7 @@ describe('Upload List', () => { it('In the case of listType=text, the error status does not show the download.', () => { const file = { status: 'error', uid: 'file' }; const wrapper = mount( - + , ); @@ -292,6 +292,9 @@ describe('Upload List', () => { }, ]} onDownload={handleDownload} + showUploadList={{ + showDownloadIcon: true, + }} > , @@ -302,7 +305,7 @@ describe('Upload List', () => { .simulate('click'); }); - it('should support no onDownload', async () => { + it('should support no onDownload', async () => { const wrapper = mount( { url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', }, ]} + showUploadList={{ + showDownloadIcon: true, + }} > , @@ -541,7 +547,13 @@ describe('Upload List', () => { it('return when prop onDownload not exists', () => { const file = new File([''], 'test.txt', { type: 'text/plain' }); const items = [{ uid: 'upload-list-item', url: '' }]; - const wrapper = mount().instance(); + const wrapper = mount( + , + ).instance(); expect(wrapper.handleDownload(file)).toBe(undefined); }); @@ -563,6 +575,7 @@ describe('Upload List', () => { items={items} onDownload={() => {}} locale={{ downloadFile: '' }} + showUploadList={{ showDownloadIcon: true }} />, ).instance(); return wrapper.props.onDownload(file); @@ -576,16 +589,20 @@ describe('Upload List', () => { expect(wrapper.find('.ant-upload-list-item-thumbnail').length).toBe(2); }); - it('extname should work correctly when url exists', () => { + it('extname should work correctly when url exists', (done) => { const items = [{ status: 'done', uid: 'upload-list-item', url: '/example' }]; const wrapper = mount( { expect(file.url).toBe('/example'); + done(); }} items={items} locale={{ downloadFile: '' }} + showUploadList={{ + showDownloadIcon: true, + }} />, ); wrapper.find('div.ant-upload-list-item i.anticon-download').simulate('click'); diff --git a/components/upload/demo/defaultFileList.md b/components/upload/demo/defaultFileList.md index 04e4b03f0146..270d84043ec6 100644 --- a/components/upload/demo/defaultFileList.md +++ b/components/upload/demo/defaultFileList.md @@ -23,6 +23,9 @@ const props = { console.log(file, fileList); } }, + showUploadList:{ + showDownloadIcon: true, + }, defaultFileList: [ { uid: '1', diff --git a/components/upload/style/index.less b/components/upload/style/index.less index b97549155527..b074e4615b71 100644 --- a/components/upload/style/index.less +++ b/components/upload/style/index.less @@ -178,7 +178,7 @@ opacity: 1; } .anticon { - padding-right: 5px; + padding-right: 6px; color: rgba(0, 0, 0, 0.45); } } @@ -239,7 +239,6 @@ &-error &-card-actions { .anticon { - padding-right: 5px; color: @error-color; } opacity: 1;