Commit e4c43737 authored by Alan Wei's avatar Alan Wei Committed by ι™ˆεΈ…

fix functionName typo from getMeunMatcheys to getMeunMatchKeys

parent 29e9547d
...@@ -22,7 +22,7 @@ const getIcon = icon => { ...@@ -22,7 +22,7 @@ const getIcon = icon => {
return icon; return icon;
}; };
export const getMeunMatcheys = (flatMenuKeys, path) => { export const getMeunMatchKeys = (flatMenuKeys, path) => {
return flatMenuKeys.filter(item => { return flatMenuKeys.filter(item => {
return pathToRegexp(item).test(path); return pathToRegexp(item).test(path);
}); });
...@@ -53,7 +53,7 @@ export default class SiderMenu extends PureComponent { ...@@ -53,7 +53,7 @@ export default class SiderMenu extends PureComponent {
const { location: { pathname } } = props || this.props; const { location: { pathname } } = props || this.props;
return urlToList(pathname) return urlToList(pathname)
.map(item => { .map(item => {
return getMeunMatcheys(this.flatMenuKeys, item)[0]; return getMeunMatchKeys(this.flatMenuKeys, item)[0];
}) })
.filter(item => item); .filter(item => item);
} }
...@@ -159,7 +159,7 @@ export default class SiderMenu extends PureComponent { ...@@ -159,7 +159,7 @@ export default class SiderMenu extends PureComponent {
// Get the currently selected menu // Get the currently selected menu
getSelectedMenuKeys = () => { getSelectedMenuKeys = () => {
const { location: { pathname } } = this.props; const { location: { pathname } } = this.props;
return urlToList(pathname).map(itemPath => getMeunMatcheys(this.flatMenuKeys, itemPath).pop()); return urlToList(pathname).map(itemPath => getMeunMatchKeys(this.flatMenuKeys, itemPath).pop());
}; };
// conversion Path // conversion Path
// θ½¬εŒ–θ·―εΎ„ // θ½¬εŒ–θ·―εΎ„
......
import { getMeunMatcheys } from './SiderMenu'; import { getMeunMatchKeys } from './SiderMenu';
const meun = ['/dashboard', '/userinfo', '/dashboard/name', '/userinfo/:id', '/userinfo/:id/info']; const meun = ['/dashboard', '/userinfo', '/dashboard/name', '/userinfo/:id', '/userinfo/:id/info'];
describe('test meun match', () => { describe('test meun match', () => {
it('simple path', () => { it('simple path', () => {
expect(getMeunMatcheys(meun, '/dashboard')).toEqual(['/dashboard']); expect(getMeunMatchKeys(meun, '/dashboard')).toEqual(['/dashboard']);
}); });
it('error path', () => { it('error path', () => {
expect(getMeunMatcheys(meun, '/dashboardname')).toEqual([]); expect(getMeunMatchKeys(meun, '/dashboardname')).toEqual([]);
}); });
it('Secondary path', () => { it('Secondary path', () => {
expect(getMeunMatcheys(meun, '/dashboard/name')).toEqual(['/dashboard/name']); expect(getMeunMatchKeys(meun, '/dashboard/name')).toEqual(['/dashboard/name']);
}); });
it('Parameter path', () => { it('Parameter path', () => {
expect(getMeunMatcheys(meun, '/userinfo/2144')).toEqual(['/userinfo/:id']); expect(getMeunMatchKeys(meun, '/userinfo/2144')).toEqual(['/userinfo/:id']);
}); });
it('three parameter path', () => { it('three parameter path', () => {
expect(getMeunMatcheys(meun, '/userinfo/2144/info')).toEqual(['/userinfo/:id/info']); expect(getMeunMatchKeys(meun, '/userinfo/2144/info')).toEqual(['/userinfo/:id/info']);
}); });
}); });
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment