From fc09ab1f4cddc34d87592f53d09dc72564a31b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 7 Jul 2020 01:22:47 +0800 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=93=A6=20package:=20remove=20father=20?= =?UTF-8?q?(#538)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📦 package: remove father * fix ts lint * fix tsc error --- example/src/e2e/baseLayout.e2e.js | 57 ----------------------------- package.json | 7 ++-- src/SiderMenu/BaseMenu.tsx | 6 +-- tests/__tests__/compatible.test.tsx | 2 +- tsconfig.json | 6 ++- 5 files changed, 12 insertions(+), 66 deletions(-) delete mode 100644 example/src/e2e/baseLayout.e2e.js diff --git a/example/src/e2e/baseLayout.e2e.js b/example/src/e2e/baseLayout.e2e.js deleted file mode 100644 index f328adac..00000000 --- a/example/src/e2e/baseLayout.e2e.js +++ /dev/null @@ -1,57 +0,0 @@ -const { uniq } = require('lodash'); -const RouterConfig = require('../../config/config').default.routes; - -const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; - -function formatter(routes, parentPath = '') { - const fixedParentPath = parentPath.replace(/\/{1,}/g, '/'); - let result = []; - routes.forEach((item) => { - if (item.path) { - result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/')); - } - if (item.routes) { - result = result.concat( - formatter(item.routes, item.path ? `${fixedParentPath}/${item.path}` : parentPath), - ); - } - }); - return uniq(result.filter((item) => !!item)); -} - -beforeEach(async () => { - await page.goto(`${BASE_URL}`); - await page.evaluate(() => { - localStorage.setItem('antd-pro-authority', '["admin"]'); - }); -}); - -describe('Ant Design Pro E2E test', () => { - const testPage = (path) => async () => { - await page.goto(`${BASE_URL}${path}`); - await page.waitForSelector('footer', { - timeout: 2000, - }); - const haveFooter = await page.evaluate( - () => document.getElementsByTagName('footer').length > 0, - ); - expect(haveFooter).toBeTruthy(); - }; - - const routers = formatter(RouterConfig); - routers.forEach((route) => { - it(`test pages ${route}`, testPage(route)); - }); - - it('topmenu should have footer', async () => { - const params = '?navTheme=light&layout=topmenu'; - await page.goto(`${BASE_URL}${params}`); - await page.waitForSelector('footer', { - timeout: 2000, - }); - const haveFooter = await page.evaluate( - () => document.getElementsByTagName('footer').length > 0, - ); - expect(haveFooter).toBeTruthy(); - }); -}); diff --git a/package.json b/package.json index c61ddca1..21050127 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "/dist" ], "scripts": { - "build": "father build && webpack", + "build": "father-build && webpack", "start": "dumi dev", "lint": "npm run lint-eslint && npm run lint:style", "lint-eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", @@ -45,7 +45,7 @@ "site": "dumi build && gh-pages -d ./dist", "site_build": "dumi build", "doc": "cd ./example && umi dev", - "test": "father test", + "test": "umi-test", "tsc": "tsc" }, "husky": { @@ -122,7 +122,7 @@ "enzyme": "^3.11.0", "enzyme-to-json": "^3.4.3", "eslint": "^7.2.0", - "father": "^2.26.0", + "father-build": "^1.18.1", "gh-pages": "^3.1.0", "husky": "^4.0.0", "jsdom": "^16.2.0", @@ -143,6 +143,7 @@ "typescript": "^3.8.3", "umi": "^3.0.0", "umi-plugin-githubpages": "^2.0.0", + "umi-test": "^1.9.6", "umi-types": "^0.5.11", "webpack-cli": "^3.3.10" }, diff --git a/src/SiderMenu/BaseMenu.tsx b/src/SiderMenu/BaseMenu.tsx index b74de74f..28332885 100644 --- a/src/SiderMenu/BaseMenu.tsx +++ b/src/SiderMenu/BaseMenu.tsx @@ -233,7 +233,7 @@ class MenuUtil { * @param BaseMenuProps */ const getOpenKeysProps = ( - openKeys: string[] | false = [], + openKeys: React.ReactText[] | false = [], { layout, collapsed }: BaseMenuProps, ): { openKeys?: undefined | string[]; @@ -276,7 +276,7 @@ const BaseMenu: React.FC = (props) => { const [defaultOpenAll, setDefaultOpenAll] = useState(menu.defaultOpenAll); const [openKeys, setOpenKeys] = useMergeValue< - WithFalse + WithFalse >( () => { if (menu.defaultOpenAll) { @@ -398,7 +398,7 @@ const BaseMenu: React.FC = (props) => { selectedKeys={selectedKeys} style={style} className={cls} - onOpenChange={setOpenKeys} + onOpenChange={(keys) => setOpenKeys(keys as string[])} {...props.menuProps} > {menuUtils.getNavMenuItems( diff --git a/tests/__tests__/compatible.test.tsx b/tests/__tests__/compatible.test.tsx index 8b58da56..cd5a4eb7 100644 --- a/tests/__tests__/compatible.test.tsx +++ b/tests/__tests__/compatible.test.tsx @@ -1,4 +1,4 @@ -import { mount, render } from 'enzyme'; +import { mount } from 'enzyme'; import React from 'react'; import BasicLayout from '../../src/BasicLayout'; diff --git a/tsconfig.json b/tsconfig.json index b25a8269..0c1371f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,7 @@ "@ant-design/pro-layout": ["./src"] } }, - "include": ["**/tests/", "**/src/", "**/docs/"], + "include": ["**/src/", "**/docs/"], "exclude": [ "node_modules", "build", @@ -31,6 +31,8 @@ "jest", "tslint:latest", "tslint-config-prettier", - "example" + "example", + "**/tests/", + "**/docs/" ] }