diff --git a/src/components/SiderMenu/BaseMeun.js b/src/components/SiderMenu/BaseMenu.js
similarity index 95%
rename from src/components/SiderMenu/BaseMeun.js
rename to src/components/SiderMenu/BaseMenu.js
index a72faa705816b7df7a78aa522ad87f78115edd0a..7c074d383205071ad67cef983e5911c15a79b6ea 100644
--- a/src/components/SiderMenu/BaseMeun.js
+++ b/src/components/SiderMenu/BaseMenu.js
@@ -21,13 +21,13 @@ const getIcon = icon => {
return icon;
};
-export const getMeunMatcheys = (flatMenuKeys, path) => {
+export const getMenuMatches = (flatMenuKeys, path) => {
return flatMenuKeys.filter(item => {
return pathToRegexp(item).test(path);
});
};
-export default class BaseMeun extends PureComponent {
+export default class BaseMenu extends PureComponent {
constructor(props) {
super(props);
this.menus = props.menuData;
@@ -68,7 +68,7 @@ export default class BaseMeun extends PureComponent {
// Get the currently selected menu
getSelectedMenuKeys = () => {
const { location: { pathname } } = this.props;
- return urlToList(pathname).map(itemPath => getMeunMatcheys(this.flatMenuKeys, itemPath).pop());
+ return urlToList(pathname).map(itemPath => getMenuMatches(this.flatMenuKeys, itemPath).pop());
};
/**
* get SubMenu or Item
diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js
index c64259ec18c521f2a4672783a9fc481042dab5f1..ce23210736c05231bb9dbb27d0a6b2c64c0f43fc 100644
--- a/src/components/SiderMenu/SiderMenu.js
+++ b/src/components/SiderMenu/SiderMenu.js
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import { Layout, Menu, Icon } from 'antd';
import { Link } from 'dva/router';
import styles from './index.less';
-import BaseMeun, { getMeunMatcheys } from './BaseMeun';
+import BaseMenu, { getMenuMatches } from './BaseMenu';
import { urlToList } from '../_utils/pathTools';
const { Sider } = Layout;
@@ -131,7 +131,7 @@ export default class SiderMenu extends PureComponent {
const { location: { pathname } } = props || this.props;
return urlToList(pathname)
.map(item => {
- return getMeunMatcheys(this.flatMenuKeys, item)[0];
+ return getMenuMatches(this.flatMenuKeys, item)[0];
})
.filter(item => item);
}
@@ -165,7 +165,7 @@ export default class SiderMenu extends PureComponent {
Ant Design Pro
- {
+ it('simple path', () => {
+ expect(getMenuMatches(menu, '/dashboard')).toEqual(['/dashboard']);
+ });
+ it('error path', () => {
+ expect(getMenuMatches(menu, '/dashboardname')).toEqual([]);
+ });
+
+ it('Secondary path', () => {
+ expect(getMenuMatches(menu, '/dashboard/name')).toEqual(['/dashboard/name']);
+ });
+
+ it('Parameter path', () => {
+ expect(getMenuMatches(menu, '/userinfo/2144')).toEqual(['/userinfo/:id']);
+ });
+
+ it('three parameter path', () => {
+ expect(getMenuMatches(menu, '/userinfo/2144/info')).toEqual(['/userinfo/:id/info']);
+ });
+});
diff --git a/src/components/SiderMenu/SilderMenu.test.js b/src/components/SiderMenu/SilderMenu.test.js
deleted file mode 100644
index 09bc20e1dea710e6b323c2d7438c4da5bfd0eb8c..0000000000000000000000000000000000000000
--- a/src/components/SiderMenu/SilderMenu.test.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import { getMeunMatcheys } from './BaseMeun';
-
-const meun = ['/dashboard', '/userinfo', '/dashboard/name', '/userinfo/:id', '/userinfo/:id/info'];
-
-describe('test meun match', () => {
- it('simple path', () => {
- expect(getMeunMatcheys(meun, '/dashboard')).toEqual(['/dashboard']);
- });
- it('error path', () => {
- expect(getMeunMatcheys(meun, '/dashboardname')).toEqual([]);
- });
-
- it('Secondary path', () => {
- expect(getMeunMatcheys(meun, '/dashboard/name')).toEqual(['/dashboard/name']);
- });
-
- it('Parameter path', () => {
- expect(getMeunMatcheys(meun, '/userinfo/2144')).toEqual(['/userinfo/:id']);
- });
-
- it('three parameter path', () => {
- expect(getMeunMatcheys(meun, '/userinfo/2144/info')).toEqual(['/userinfo/:id/info']);
- });
-});
diff --git a/src/components/TopNavHeader/index.js b/src/components/TopNavHeader/index.js
index ebe054b27d328145eb8b9f3be179223bcd9b6a63..6482dae1d65ce42b1a43e4b6861c6970337d9960 100644
--- a/src/components/TopNavHeader/index.js
+++ b/src/components/TopNavHeader/index.js
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import { Link } from 'dva/router';
import RightContent from '../GlobalHeader/RightContent';
-import BaseMeun from '../SiderMenu/BaseMeun';
+import BaseMenu from '../SiderMenu/BaseMenu';
import styles from './index.less';
export default class TopNavHeader extends PureComponent {
@@ -24,7 +24,7 @@ export default class TopNavHeader extends PureComponent {
Ant Design Pro
-