From e31e4ae3d7f0fed95b061ca131b4a965d6eaab7e Mon Sep 17 00:00:00 2001 From: chenshuai2144 Date: Tue, 7 Jul 2020 00:48:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bug:=20support=20menuContentRend?= =?UTF-8?q?er=3D=3Dfalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SiderMenu/SiderMenu.tsx | 4 ++- tests/__tests__/index.test.tsx | 14 +++++++++- tests/__tests__/pageContainer.test.tsx | 37 +++++++++++++++++++++++++- tsconfig.json | 5 ++-- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/SiderMenu/SiderMenu.tsx b/src/SiderMenu/SiderMenu.tsx index 89d5c0e4..d5d855b7 100644 --- a/src/SiderMenu/SiderMenu.tsx +++ b/src/SiderMenu/SiderMenu.tsx @@ -110,8 +110,10 @@ const SiderMenu: React.FC = (props) => { }); const headerDom = defaultRenderLogoAndTitle(props); + const extraDom = menuExtraRender && menuExtraRender(props); - const menuDom = flatMenuKeys && ( + + const menuDom = menuContentRender !== false && flatMenuKeys && ( { it('🥩 do not render menu', async () => { const wrapper = mount(); await waitForComponentToPaint(wrapper); - const menu = wrapper.find('.ant-pro-sider-menu'); + const menu = wrapper.find('.ant-pro-sider'); expect(menu.exists()).toBe(false); + const menuContent = wrapper.find('.ant-pro-sider-menu'); + expect(menuContent.exists()).toBe(false); expect( ( wrapper.find('section.ant-layout section.ant-layout').props().style || @@ -40,6 +42,16 @@ describe('BasicLayout', () => { wrapper.unmount(); }); + it('🥩 do not render menu content', async () => { + const wrapper = mount(); + await waitForComponentToPaint(wrapper); + const menu = wrapper.find('.ant-pro-sider'); + expect(menu.exists()).toBe(true); + const menuContent = wrapper.find('.ant-pro-sider-menu'); + expect(menuContent.exists()).toBe(false); + wrapper.unmount(); + }); + it('🥩 support menuDateRender', async () => { const wrapper = mount( { '100%', ); }); + + it('🐲 FooterToolbar should know width', async () => { + const wrapper = mount( + + + + + + + , + ); + await waitForComponentToPaint(wrapper); + + expect(wrapper.find('.ant-pro-footer-bar').props().style.width).toBe( + 'calc(100% - 208px)', + ); + wrapper.setProps({ + collapsed: true, + }); + + await waitForComponentToPaint(wrapper); + + expect(wrapper.find('.ant-pro-footer-bar').props().style.width).toBe( + 'calc(100% - 48px)', + ); + + wrapper.setProps({ + layout: 'top', + }); + + expect(wrapper.find('.ant-pro-footer-bar').props().style.width).toBe( + '100%', + ); + }); }); diff --git a/tsconfig.json b/tsconfig.json index d87a7f97..b25a8269 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "@ant-design/pro-layout": ["./src"] } }, + "include": ["**/tests/", "**/src/", "**/docs/"], "exclude": [ "node_modules", "build", @@ -30,8 +31,6 @@ "jest", "tslint:latest", "tslint-config-prettier", - "example", - "_test_", - "tests" + "example" ] }