| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import {sortMenu} from '.';
- describe('sortMenu', function() {
- it('sortMenu 被定义', function() {
- expect(sortMenu).toBeDefined();
- expect(sortMenu).toBeInstanceOf(Function);
- });
- it('sortMenu 传入空数组', function() {
- const result = sortMenu([]);
- expect(result).toEqual([]);
- });
- it('sortMenu 正常空数组', function() {
- const result = sortMenu([{
- id: '14',
- name: '菜单管理',
- url: '/menu',
- pId: '13',
- page: 0,
- limit: 0,
- orderBy: '',
- img: '',
- }, {
- id: '23',
- name: '用户管理',
- url: '/user',
- pId: '15',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '26',
- name: '库位管理',
- url: '/storage',
- pId: '25',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '15',
- name: '用户设置',
- url: '.',
- pId: '0',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '16',
- name: '角色管理',
- url: '/role',
- pId: '15',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '27',
- name: '货品管理',
- url: '/goods',
- pId: '25',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '24',
- name: '部门管理',
- url: '/department',
- pId: '15',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '25',
- name: '仓库管理',
- url: '.',
- pId: '0',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }, {
- id: '13',
- name: '系统设置',
- url: '.',
- pId: '0',
- page: 0,
- limit: 0,
- img: '',
- orderBy: '',
- }]);
- expect(result).toEqual([{key: '15', title: '用户设置', label: '用户设置', pid: '0', url: '.', children: [{key: '23', title: '用户管理', label: '用户管理', pid: '15', url: '/user'}, {key: '16', title: '角色管理', label: '角色管理', pid: '15', url: '/role'}, {key: '24', title: '部门管理', label: '部门管理', pid: '15', url: '/department'}]}, {key: '25', title: '仓库管理', label: '仓库管理', pid: '0', url: '.', children: [{key: '26', title: '库位管理', label: '库位管理', pid: '25', url: '/storage'}, {key: '27', title: '货品管理', label: '货品管理', pid: '25', url: '/goods'}]}, {key: '13', title: '系统设置', label: '系统设置', pid: '0', url: '.', children: [{key: '14', title: '菜单管理', label: '菜单管理', pid: '13', url: '/menu'}]}]);
- });
- });
|