|
|
@@ -1,6 +1,7 @@
|
|
|
import { describe, expect, test, beforeEach, vi } from 'vitest'
|
|
|
import type { RuntimeConfig } from '@nuxt/schema'
|
|
|
import type { AnyAbility } from '@casl/ability/dist/types'
|
|
|
+import type { Router } from 'vue-router'
|
|
|
import type { AccessProfile, organizationState } from '~/types/interfaces'
|
|
|
import AccountMenuBuilder from '~/services/layout/menuBuilder/accountMenuBuilder'
|
|
|
import type { MenuGroup } from '~/types/layout'
|
|
|
@@ -12,12 +13,14 @@ let ability: AnyAbility
|
|
|
let organizationProfile: organizationState
|
|
|
let accessProfile: AccessProfile
|
|
|
let menuBuilder: AccountMenuBuilder
|
|
|
+let router: Router
|
|
|
|
|
|
beforeEach(() => {
|
|
|
runtimeConfig = vi.fn() as any as RuntimeConfig
|
|
|
ability = vi.fn() as any as AnyAbility
|
|
|
organizationProfile = vi.fn() as any as organizationState
|
|
|
accessProfile = vi.fn() as any as AccessProfile
|
|
|
+ router = vi.fn() as any as AccessProfile
|
|
|
|
|
|
runtimeConfig.baseUrlAdminLegacy = 'https://mydomain.com/'
|
|
|
accessProfile.id = 123
|
|
|
@@ -27,6 +30,7 @@ beforeEach(() => {
|
|
|
ability,
|
|
|
organizationProfile,
|
|
|
accessProfile,
|
|
|
+ router,
|
|
|
)
|
|
|
})
|
|
|
|
|
|
@@ -39,6 +43,8 @@ describe('getMenuName', () => {
|
|
|
describe('build', () => {
|
|
|
test('has all items (mister)', () => {
|
|
|
ability.can = vi.fn(() => true)
|
|
|
+ // @ts-ignore
|
|
|
+ router.resolve = vi.fn(() => 'foo')
|
|
|
|
|
|
// Should return a MenuGroup
|
|
|
const result = menuBuilder.build() as MenuGroup
|