index.test.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {sortMenu} from '.';
  2. describe('sortMenu', function() {
  3. it('sortMenu 被定义', function() {
  4. expect(sortMenu).toBeDefined();
  5. expect(sortMenu).toBeInstanceOf(Function);
  6. });
  7. it('sortMenu 传入空数组', function() {
  8. const result = sortMenu([]);
  9. expect(result).toEqual([]);
  10. });
  11. it('sortMenu 正常空数组', function() {
  12. const result = sortMenu([{
  13. id: '14',
  14. name: '菜单管理',
  15. url: '/menu',
  16. pId: '13',
  17. page: 0,
  18. limit: 0,
  19. orderBy: '',
  20. img: '',
  21. }, {
  22. id: '23',
  23. name: '用户管理',
  24. url: '/user',
  25. pId: '15',
  26. page: 0,
  27. limit: 0,
  28. img: '',
  29. orderBy: '',
  30. }, {
  31. id: '26',
  32. name: '库位管理',
  33. url: '/storage',
  34. pId: '25',
  35. page: 0,
  36. limit: 0,
  37. img: '',
  38. orderBy: '',
  39. }, {
  40. id: '15',
  41. name: '用户设置',
  42. url: '.',
  43. pId: '0',
  44. page: 0,
  45. limit: 0,
  46. img: '',
  47. orderBy: '',
  48. }, {
  49. id: '16',
  50. name: '角色管理',
  51. url: '/role',
  52. pId: '15',
  53. page: 0,
  54. limit: 0,
  55. img: '',
  56. orderBy: '',
  57. }, {
  58. id: '27',
  59. name: '货品管理',
  60. url: '/goods',
  61. pId: '25',
  62. page: 0,
  63. limit: 0,
  64. img: '',
  65. orderBy: '',
  66. }, {
  67. id: '24',
  68. name: '部门管理',
  69. url: '/department',
  70. pId: '15',
  71. page: 0,
  72. limit: 0,
  73. img: '',
  74. orderBy: '',
  75. }, {
  76. id: '25',
  77. name: '仓库管理',
  78. url: '.',
  79. pId: '0',
  80. page: 0,
  81. limit: 0,
  82. img: '',
  83. orderBy: '',
  84. }, {
  85. id: '13',
  86. name: '系统设置',
  87. url: '.',
  88. pId: '0',
  89. page: 0,
  90. limit: 0,
  91. img: '',
  92. orderBy: '',
  93. }]);
  94. 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'}]}]);
  95. });
  96. });