|
@@ -2,7 +2,7 @@ import { describe, test, it, expect } from 'vitest'
|
|
|
import type { RuntimeConfig } from '@nuxt/schema'
|
|
import type { RuntimeConfig } from '@nuxt/schema'
|
|
|
import type { AnyAbility } from '@casl/ability/dist/types'
|
|
import type { AnyAbility } from '@casl/ability/dist/types'
|
|
|
import type { AccessProfile, organizationState } from '~/types/interfaces'
|
|
import type { AccessProfile, organizationState } from '~/types/interfaces'
|
|
|
-import MedalsMenuBuilder from '~/services/layout/menuBuilder/medalsMenuBuilder'
|
|
|
|
|
|
|
+import RewardsMenuBuilder from '~/services/layout/menuBuilder/rewardsMenuBuilder'
|
|
|
import type { MenuGroup, MenuItem } from '~/types/layout'
|
|
import type { MenuGroup, MenuItem } from '~/types/layout'
|
|
|
import { MENU_LINK_TYPE } from '~/types/enum/layout'
|
|
import { MENU_LINK_TYPE } from '~/types/enum/layout'
|
|
|
|
|
|
|
@@ -10,7 +10,7 @@ let runtimeConfig: RuntimeConfig
|
|
|
let ability: AnyAbility
|
|
let ability: AnyAbility
|
|
|
let organizationProfile: organizationState
|
|
let organizationProfile: organizationState
|
|
|
let accessProfile: AccessProfile
|
|
let accessProfile: AccessProfile
|
|
|
-let menuBuilder: MedalsMenuBuilder
|
|
|
|
|
|
|
+let menuBuilder: RewardsMenuBuilder
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
|
runtimeConfig = vi.fn() as any as RuntimeConfig
|
|
runtimeConfig = vi.fn() as any as RuntimeConfig
|
|
@@ -20,7 +20,7 @@ beforeEach(() => {
|
|
|
|
|
|
|
|
runtimeConfig.baseUrlAdminLegacy = 'https://mydomain.com/'
|
|
runtimeConfig.baseUrlAdminLegacy = 'https://mydomain.com/'
|
|
|
|
|
|
|
|
- menuBuilder = new MedalsMenuBuilder(
|
|
|
|
|
|
|
+ menuBuilder = new RewardsMenuBuilder(
|
|
|
runtimeConfig,
|
|
runtimeConfig,
|
|
|
ability,
|
|
ability,
|
|
|
organizationProfile,
|
|
organizationProfile,
|
|
@@ -30,7 +30,7 @@ beforeEach(() => {
|
|
|
|
|
|
|
|
describe('getMenuName', () => {
|
|
describe('getMenuName', () => {
|
|
|
test('validate name', () => {
|
|
test('validate name', () => {
|
|
|
- expect(menuBuilder.getMenuName()).toEqual('Medals')
|
|
|
|
|
|
|
+ expect(menuBuilder.getMenuName()).toEqual('AccessRewards')
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -38,16 +38,14 @@ describe('build', () => {
|
|
|
test('has all items', () => {
|
|
test('has all items', () => {
|
|
|
ability.can = vi.fn(() => true)
|
|
ability.can = vi.fn(() => true)
|
|
|
|
|
|
|
|
- // Should return a MenuItem
|
|
|
|
|
- const result = menuBuilder.build() as MenuItem
|
|
|
|
|
|
|
+ // Should return a MenuGroup
|
|
|
|
|
+ const result = menuBuilder.build() as MenuGroup
|
|
|
|
|
|
|
|
expect(result).toEqual({
|
|
expect(result).toEqual({
|
|
|
- label: 'medals',
|
|
|
|
|
- icon: { name: 'fas fa-trophy' },
|
|
|
|
|
- to: 'https://mydomain.com/#/medals/list/',
|
|
|
|
|
- type: MENU_LINK_TYPE.V1,
|
|
|
|
|
- active: false,
|
|
|
|
|
|
|
+ label: 'access_rewards',
|
|
|
})
|
|
})
|
|
|
|
|
+ // @ts-ignore
|
|
|
|
|
+ expect(result.children.length).toEqual(3)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
test('has no items', () => {
|
|
test('has no items', () => {
|