20 lines
775 B
TypeScript
20 lines
775 B
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { http } from '@/shared/api/http'
|
|
import { listCurrentPlatformPermissionCodes } from './platformAuthorization'
|
|
|
|
vi.mock('@/shared/api/http', () => ({
|
|
http: { get: vi.fn() },
|
|
unwrapApiResponse: <T>(response: { data: T }) => response.data,
|
|
}))
|
|
|
|
describe('platformAuthorization', () => {
|
|
beforeEach(() => vi.clearAllMocks())
|
|
|
|
it('loads the current user permission snapshot', async () => {
|
|
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'success', data: ['platform:warehouse:list'] })
|
|
|
|
await expect(listCurrentPlatformPermissionCodes()).resolves.toEqual(['platform:warehouse:list'])
|
|
expect(http.get).toHaveBeenCalledWith('/platform/v1/iam/authorization/permissions')
|
|
})
|
|
})
|