import { describe, it, expect } from 'vitest'; import { isAdminProfile, type UserProfile } from './token'; const base: UserProfile = { userId: 'U1', account: 'user', name: '张三', roles: [] }; describe('isAdminProfile', () => { it('account 为 admin 判为管理员', () => { expect(isAdminProfile({ ...base, account: 'admin' })).toBe(true); }); it('userId 为 ADMIN 判为管理员', () => { expect(isAdminProfile({ ...base, userId: 'ADMIN' })).toBe(true); }); it('普通用户(account/userId 均非管理员)判否', () => { expect(isAdminProfile(base)).toBe(false); }); it('null / undefined 判否', () => { expect(isAdminProfile(null)).toBe(false); expect(isAdminProfile(undefined)).toBe(false); }); });