37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mapPlatformPermission } from '@/utils/platformPermission'
|
|
|
|
describe('mapPlatformPermission', () => {
|
|
it('treats the string root parent as a root node and preserves long ids', () => {
|
|
expect(mapPlatformPermission({
|
|
id: '2082813911786024961',
|
|
tenantId: '0',
|
|
appCode: 'PLATFORM',
|
|
permissionType: 'MENU',
|
|
parentId: '0',
|
|
permissionCode: 'platform:audit',
|
|
permissionName: '审计管理',
|
|
routePath: '/audit',
|
|
httpMethod: null,
|
|
sortNo: 50,
|
|
status: 'ACTIVE',
|
|
})).toMatchObject({ id: '2082813911786024961', parentId: null, code: 'platform:audit' })
|
|
})
|
|
|
|
it('preserves a long string parent id for child resources', () => {
|
|
expect(mapPlatformPermission({
|
|
id: '2082813911786024962',
|
|
tenantId: '0',
|
|
appCode: 'PLATFORM',
|
|
permissionType: 'BUTTON',
|
|
parentId: '2082813911786024961',
|
|
permissionCode: 'platform:audit:list',
|
|
permissionName: '操作日志',
|
|
routePath: null,
|
|
httpMethod: null,
|
|
sortNo: 10,
|
|
status: 'ACTIVE',
|
|
})).toMatchObject({ id: '2082813911786024962', parentId: '2082813911786024961', type: '按钮' })
|
|
})
|
|
})
|