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:
Tiago Yamamoto 2025-12-24 16:32:25 -03:00
parent 37c339e34e
commit dec9dc4897

View file

@ -194,17 +194,17 @@ describe('Auth Module', () => {
describe('isAdminUser', () => { describe('isAdminUser', () => {
it('should return true for admin role', () => { 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); expect(authModule.isAdminUser(adminUser)).toBe(true);
}); });
it('should return true for SUPERADMIN in roles array', () => { 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); expect(authModule.isAdminUser(superAdmin)).toBe(true);
}); });
it('should return false for regular candidate', () => { 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); expect(authModule.isAdminUser(candidate)).toBe(false);
}); });