fix(frontend): fix TypeScript errors in auth.test.ts
- Add 'as const' to role literals for proper type inference - Fixes build error: Type 'string' not assignable to 'candidate' | 'admin' | 'company'
This commit is contained in:
parent
37c339e34e
commit
dec9dc4897
1 changed files with 3 additions and 3 deletions
|
|
@ -194,17 +194,17 @@ describe('Auth Module', () => {
|
|||
|
||||
describe('isAdminUser', () => {
|
||||
it('should return true for admin role', () => {
|
||||
const adminUser = { id: '1', name: 'Admin', email: 'a@a.com', role: 'admin', roles: ['admin'] };
|
||||
const adminUser = { id: '1', name: 'Admin', email: 'a@a.com', role: 'admin' as const, roles: ['admin'] };
|
||||
expect(authModule.isAdminUser(adminUser)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for SUPERADMIN in roles array', () => {
|
||||
const superAdmin = { id: '1', name: 'Super', email: 's@s.com', role: 'candidate', roles: ['SUPERADMIN'] };
|
||||
const superAdmin = { id: '1', name: 'Super', email: 's@s.com', role: 'candidate' as const, roles: ['SUPERADMIN'] };
|
||||
expect(authModule.isAdminUser(superAdmin)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for regular candidate', () => {
|
||||
const candidate = { id: '1', name: 'User', email: 'u@u.com', role: 'candidate', roles: ['CANDIDATE'] };
|
||||
const candidate = { id: '1', name: 'User', email: 'u@u.com', role: 'candidate' as const, roles: ['CANDIDATE'] };
|
||||
expect(authModule.isAdminUser(candidate)).toBe(false);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue