menu.spec.ts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. import BaseMenu from "~/use/layout/Menus/baseMenu";
  2. describe('constructMenu()', () => {
  3. it('should construct a menu without children', () => {
  4. const menuWithoutChildren = new BaseMenu({'baseURL_adminLegacy': 'base_url'}).constructMenu('children', 'icon', '/url', false)
  5. expect(menuWithoutChildren).toStrictEqual({
  6. title: "children",
  7. icon: "icon",
  8. to: "/url",
  9. isExternalLink: false
  10. });
  11. })
  12. it('should construct a menu with children', () => {
  13. const menuWithoutChildren = new BaseMenu({'baseURL_adminLegacy': 'base_url'}).constructMenu('children', 'icon', '/url', false)
  14. const menuWithChildren = new BaseMenu({'baseURL_adminLegacy': 'base_url'}).constructMenu('parent', 'icon', undefined, undefined, [menuWithoutChildren])
  15. expect(menuWithChildren).toStrictEqual({
  16. children: [
  17. {
  18. title: "children",
  19. icon: "icon",
  20. to: "/url",
  21. isExternalLink: false
  22. }
  23. ],
  24. icon: "icon",
  25. title: "parent"
  26. });
  27. })
  28. })