Skip to content

Commit c3a3869

Browse files
✅ tests: fast test example (#50)
1 parent 94291f0 commit c3a3869

File tree

15 files changed

+26
-263
lines changed

15 files changed

+26
-263
lines changed

example/package.json

+5-84
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,25 @@
44
"private": true,
55
"description": "An out-of-box UI solution for enterprise applications",
66
"scripts": {
7-
"analyze": "cross-env ANALYZE=1 umi build",
8-
"build": "umi build",
9-
"deploy": "npm run site && npm run gh-pages",
10-
"fetch:blocks": "pro fetch-blocks --branch antd@4 && npm run prettier",
11-
"format-imports": "cross-env import-sort --write '**/*.{js,jsx,ts,tsx}'",
12-
"gh-pages": "cp CNAME ./dist/ && gh-pages -d dist",
13-
"i18n-remove": "pro i18n-remove --locale=zh-CN --write",
147
"lint": "npm run lint:js && npm run lint:style && npm run lint:prettier",
158
"lint-staged": "lint-staged",
169
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
1710
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
1811
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
1912
"lint:prettier": "prettier --check \"**/*\" --end-of-line auto",
2013
"lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
21-
"prettier": "prettier -c --write \"**/*\"",
22-
"start": "umi dev",
23-
"start:no-mock": "cross-env MOCK=none umi dev",
24-
"start:no-ui": "cross-env UMI_UI=none umi dev",
25-
"test": "umi test",
26-
"test:all": "node ./tests/run-tests.js",
27-
"test:component": "umi test ./src/components",
28-
"tsc": "tsc",
29-
"ui": "umi ui"
14+
"prettier": "prettier -c --write \"**/*\""
3015
},
31-
"husky": {
32-
"hooks": {
33-
"pre-commit": "npm run lint-staged"
34-
}
35-
},
36-
"lint-staged": {
37-
"**/*.less": "stylelint --syntax less",
38-
"**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
39-
"**/*.{js,jsx,tsx,ts,less,md,json}": [
40-
"prettier --write",
41-
"git add"
42-
]
43-
},
44-
"browserslist": [
45-
"> 1%",
46-
"last 2 versions",
47-
"not ie <= 10"
48-
],
4916
"dependencies": {
50-
"@ant-design/compatible": "^0.0.1-rc.0",
17+
"@ant-design/compatible": "^1.0.0",
5118
"@ant-design/icons": "^4.0.0-alpha.19",
5219
"@ant-design/pro-layout": "^5.0.0",
5320
"@ant-design/pro-table": "^2.0.0",
5421
"@antv/data-set": "^0.10.2",
5522
"@types/lodash.debounce": "^4.0.6",
5623
"@types/lodash.isequal": "^4.5.5",
5724
"@types/numeral": "^0.0.26",
58-
"antd": "^4.0.0-rc.1",
25+
"antd": "^4.0.0",
5926
"bizcharts": "^3.5.3-beta.0",
6027
"bizcharts-plugin-slider": "^2.1.1-beta.1",
6128
"classnames": "^2.2.6",
@@ -70,62 +37,16 @@
7037
"path-to-regexp": "2.4.0",
7138
"qs": "^6.9.0",
7239
"react": "^16.8.6",
73-
"react-copy-to-clipboard": "^5.0.1",
7440
"react-dom": "^16.8.6",
7541
"react-fittext": "^1.0.0",
7642
"react-helmet": "^5.2.1",
7743
"redux": "^4.0.1",
78-
"umi": "^2.13.0",
79-
"umi-plugin-antd-icon-config": "^1.0.2",
80-
"umi-plugin-antd-theme": "^1.0.1",
81-
"umi-plugin-pro-block": "^1.3.2",
44+
"umi": "^3.2.7",
8245
"umi-plugin-react": "^1.14.10",
8346
"umi-request": "^1.0.8",
8447
"use-merge-value": "^1.0.1"
8548
},
86-
"devDependencies": {
87-
"@ant-design/pro-cli": "^1.0.17",
88-
"@types/classnames": "^2.2.7",
89-
"@types/express": "^4.17.0",
90-
"@types/history": "^4.7.2",
91-
"@types/jest": "^24.0.24",
92-
"@types/lodash": "^4.14.144",
93-
"@types/qs": "^6.5.3",
94-
"@types/react": "^16.9.17",
95-
"@types/react-dom": "^16.8.4",
96-
"@types/react-helmet": "^5.0.13",
97-
"@umijs/fabric": "2.0.0",
98-
"chalk": "^3.0.0",
99-
"check-prettier": "^1.0.3",
100-
"cross-env": "^6.0.0",
101-
"cross-port-killer": "^1.1.1",
102-
"enzyme": "^3.11.0",
103-
"express": "^4.17.1",
104-
"gh-pages": "^2.0.1",
105-
"husky": "^4.0.7",
106-
"import-sort-cli": "^6.0.0",
107-
"import-sort-parser-babylon": "^6.0.0",
108-
"import-sort-parser-typescript": "^6.0.0",
109-
"import-sort-style-module": "^6.0.0",
110-
"jsdom-global": "^3.0.2",
111-
"lint-staged": "^9.0.0",
112-
"mockjs": "^1.0.1-beta3",
113-
"node-fetch": "^2.6.0",
114-
"prettier": "^2.0.1",
115-
"pro-download": "1.0.1",
116-
"stylelint": "^13.0.0",
117-
"umi-plugin-ga": "^1.1.3",
118-
"umi-plugin-pro": "^1.0.2",
119-
"umi-types": "^0.5.9"
120-
},
12149
"engines": {
12250
"node": ">=10.0.0"
123-
},
124-
"checkFiles": [
125-
"src/**/*.js*",
126-
"src/**/*.ts*",
127-
"src/**/*.less",
128-
"config/**/*.js*",
129-
"scripts/**/*.js"
130-
]
51+
}
13152
}

example/src/components/Authorized/CheckPermissions.tsx

+8-12
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,15 @@ const checkPermissions = <T, K>(
5757
}
5858
// Function 处理
5959
if (typeof authority === 'function') {
60-
try {
61-
const bool = authority(currentAuthority);
62-
// 函数执行后返回值是 Promise
63-
if (bool instanceof Promise) {
64-
return <PromiseRender<T, K> ok={target} error={Exception} promise={bool} />;
65-
}
66-
if (bool) {
67-
return target;
68-
}
69-
return Exception;
70-
} catch (error) {
71-
throw error;
60+
const bool = authority(currentAuthority);
61+
// 函数执行后返回值是 Promise
62+
if (bool instanceof Promise) {
63+
return <PromiseRender<T, K> ok={target} error={Exception} promise={bool} />;
7264
}
65+
if (bool) {
66+
return target;
67+
}
68+
return Exception;
7369
}
7470
throw new Error('unsupported parameters');
7571
};

example/src/components/SelectLang/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GlobalOutlined } from '@ant-design/icons';
22
import { Menu } from 'antd';
3-
import { getLocale, setLocale } from 'umi-plugin-react/locale';
3+
import { getLocale, setLocale } from 'umi';
44
import { ClickParam } from 'antd/es/menu';
55
import React from 'react';
66
import classNames from 'classnames';

example/src/global.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, message, notification } from 'antd';
22

33
import React from 'react';
4-
import { formatMessage } from 'umi-plugin-react/locale';
4+
import { formatMessage } from 'umi';
55
import defaultSettings from '../config/defaultSettings';
66

77
const { pwa } = defaultSettings;

example/src/layouts/BasicLayout.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import ProLayout, {
99
Settings,
1010
DefaultFooter,
1111
} from '@ant-design/pro-layout';
12-
import { formatMessage } from 'umi-plugin-react/locale';
12+
import { formatMessage, Link } from 'umi';
1313
import React, { useEffect } from 'react';
14-
import { Link } from 'umi';
1514
import { Dispatch } from 'redux';
1615
import { connect } from 'dva';
1716
import { GithubOutlined } from '@ant-design/icons';

example/src/layouts/UserLayout.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { DefaultFooter, MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout';
22
import { Helmet } from 'react-helmet';
3-
import { Link } from 'umi';
3+
import { Link, formatMessage } from 'umi';
44
import React from 'react';
5-
import { formatMessage } from 'umi-plugin-react/locale';
65
import { connect } from 'dva';
76
import SelectLang from '@/components/SelectLang';
87
import { ConnectProps, ConnectState } from '@/models/connect';

example/src/pages/DashboardAnalysis/components/Charts/ChartCard/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import React from 'react';
44
import classNames from 'classnames';
55
import styles from './index.less';
66

7-
type totalType = () => React.ReactNode;
7+
type TotalType = () => React.ReactNode;
88

9-
const renderTotal = (total?: number | totalType | React.ReactNode) => {
9+
const renderTotal = (total?: number | TotalType | React.ReactNode) => {
1010
if (!total && total !== 0) {
1111
return null;
1212
}

example/src/pages/DashboardAnalysis/components/IntroduceRow.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { InfoCircleOutlined } from '@ant-design/icons';
22
import { Col, Row, Tooltip } from 'antd';
33

4-
import { FormattedMessage } from 'umi-plugin-react/locale';
4+
import { FormattedMessage } from 'umi';
55
import React from 'react';
66
import numeral from 'numeral';
77
import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from './Charts';

example/src/pages/DashboardAnalysis/components/OfflineData.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Card, Col, Row, Tabs } from 'antd';
2-
import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
2+
import { FormattedMessage, formatMessage } from 'umi';
33
import React from 'react';
44
import { OfflineChartData, OfflineDataType } from '../data.d';
55

example/src/pages/DashboardAnalysis/components/ProportionSales.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Card, Radio } from 'antd';
22

3-
import { FormattedMessage } from 'umi-plugin-react/locale';
3+
import { FormattedMessage } from 'umi';
44
import { RadioChangeEvent } from 'antd/es/radio';
55
import React from 'react';
66
import { VisitDataType } from '../data.d';

example/src/pages/DashboardAnalysis/components/SalesCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Card, Col, DatePicker, Row, Tabs } from 'antd';
2-
import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
2+
import { FormattedMessage, formatMessage } from 'umi';
33

44
import React from 'react';
55
import numeral from 'numeral';

example/src/pages/DashboardAnalysis/components/TopSearch.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { InfoCircleOutlined } from '@ant-design/icons';
22
import { Card, Col, Row, Table, Tooltip } from 'antd';
3-
import { FormattedMessage } from 'umi-plugin-react/locale';
3+
import { FormattedMessage } from 'umi';
44
import React from 'react';
55
import numeral from 'numeral';
66
import { SearchDataType, VisitDataType } from '../data.d';

example/src/pages/FormAdvancedForm/_mock.ts

-7
This file was deleted.

example/src/pages/ListTableList/_mock.ts

-146
This file was deleted.

0 commit comments

Comments
 (0)