Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
πŸ› bug: support menuContentRender==false
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jul 6, 2020
1 parent 44a3597 commit e31e4ae
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/SiderMenu/SiderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ const SiderMenu: React.FC<SiderMenuProps> = (props) => {
});

const headerDom = defaultRenderLogoAndTitle(props);

const extraDom = menuExtraRender && menuExtraRender(props);
const menuDom = flatMenuKeys && (

const menuDom = menuContentRender !== false && flatMenuKeys && (
<BaseMenu
{...props}
mode="inline"
Expand Down
14 changes: 13 additions & 1 deletion tests/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ describe('BasicLayout', () => {
it('πŸ₯© do not render menu', async () => {
const wrapper = mount(<BasicLayout menuRender={false} />);
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 ||
Expand All @@ -40,6 +42,16 @@ describe('BasicLayout', () => {
wrapper.unmount();
});

it('πŸ₯© do not render menu content', async () => {
const wrapper = mount(<BasicLayout menuContentRender={false} />);
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(
<BasicLayout
Expand Down
37 changes: 36 additions & 1 deletion tests/__tests__/pageContainer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render, mount } from 'enzyme';

import React from 'react';
import PageContainer from '../../src/PageContainer';
import FooterToolbar from '../../src/FooterToolbar';
Expand Down Expand Up @@ -126,4 +125,40 @@ describe('PageContainer', () => {
'100%',
);
});

it('🐲 FooterToolbar should know width', async () => {
const wrapper = mount<BasicLayoutProps>(
<BasicLayout>
<PageContainer>
<FooterToolbar>
<button type="button" key="button">
qixian
</button>
</FooterToolbar>
</PageContainer>
</BasicLayout>,
);
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%',
);
});
});
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@ant-design/pro-layout": ["./src"]
}
},
"include": ["**/tests/", "**/src/", "**/docs/"],
"exclude": [
"node_modules",
"build",
Expand All @@ -30,8 +31,6 @@
"jest",
"tslint:latest",
"tslint-config-prettier",
"example",
"_test_",
"tests"
"example"
]
}

0 comments on commit e31e4ae

Please sign in to comment.