diff --git a/package.json b/package.json index 68a7ea70..66c5c202 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "site_build": "dumi build", "doc": "cd ./example && umi dev", "test": "umi-test", - "tsc": "tsc" + "tsc": "tsc -p tsconfig-check.json" }, "husky": { "hooks": { diff --git a/src/SiderMenu/BaseMenu.tsx b/src/SiderMenu/BaseMenu.tsx index 28332885..045714bb 100644 --- a/src/SiderMenu/BaseMenu.tsx +++ b/src/SiderMenu/BaseMenu.tsx @@ -308,6 +308,7 @@ const BaseMenu: React.FC = (props) => { ); useEffect(() => { + setPostMenuData(menuData); if (menu.defaultOpenAll || propsOpenKeys === false || flatMenuKeys.length) { return; } diff --git a/tests/__tests__/__snapshots__/index.test.tsx.snap b/tests/__tests__/__snapshots__/index.test.tsx.snap index df3ae69c..a7f36384 100644 --- a/tests/__tests__/__snapshots__/index.test.tsx.snap +++ b/tests/__tests__/__snapshots__/index.test.tsx.snap @@ -207,6 +207,232 @@ exports[`BasicLayout 🥩 contentStyle should change dom 1`] = ` `; +exports[`BasicLayout 🥩 menuDataRender change date 1`] = ` +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+`; + +exports[`BasicLayout 🥩 menuDataRender change date 2`] = ` +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+`; + exports[`BasicLayout 🥩 support loading 1`] = `
`; -exports[`BasicLayout 🥩 support menuDateRender 1`] = ` +exports[`BasicLayout 🥩 support menuDataRender 1`] = `
diff --git a/tests/__tests__/index.test.tsx b/tests/__tests__/index.test.tsx index d366c16b..c51b68a2 100644 --- a/tests/__tests__/index.test.tsx +++ b/tests/__tests__/index.test.tsx @@ -52,7 +52,7 @@ describe('BasicLayout', () => { wrapper.unmount(); }); - it('🥩 support menuDateRender', async () => { + it('🥩 support menuDataRender', async () => { const wrapper = mount( @@ -222,6 +222,36 @@ describe('BasicLayout', () => { wrapper.unmount(); }); + it('🥩 menuDataRender change date', async () => { + const wrapper = mount( []} />); + await waitForComponentToPaint(wrapper); + + expect(wrapper.render()).toMatchSnapshot(); + + wrapper.setProps({ + menuDataRender: () => [ + { + path: '/home', + name: '首页', + children: [ + { + path: '/home/overview', + name: '概述', + exact: true, + }, + { + path: '/home/search', + name: '搜索', + exact: true, + }, + ], + }, + ], + }); + await waitForComponentToPaint(wrapper); + expect(wrapper.render()).toMatchSnapshot(); + }); + it('🥩 use onLogoClick', async () => { const onLogoClick = jest.fn(); const wrapper = mount( diff --git a/tsconfig-check.json b/tsconfig-check.json new file mode 100644 index 00000000..da3c8dbf --- /dev/null +++ b/tsconfig-check.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "outDir": "build/dist", + "module": "esnext", + "target": "ES2015", + "lib": ["esnext", "dom"], + "sourceMap": true, + "baseUrl": ".", + "jsx": "react", + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true, + "experimentalDecorators": true, + "strict": true, + "declaration": true, + "skipLibCheck": true, + "paths": { + "@ant-design/pro-layout": ["./src"] + } + }, + "include": ["src/"] +} diff --git a/tsconfig.json b/tsconfig.json index 0c1371f3..d28504c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,7 @@ "@ant-design/pro-layout": ["./src"] } }, - "include": ["**/src/", "**/docs/"], + "include": ["**/src/", "**/docs/", "**/tests/"], "exclude": [ "node_modules", "build", @@ -32,7 +32,6 @@ "tslint:latest", "tslint-config-prettier", "example", - "**/tests/", "**/docs/" ] }