Files
HIPCTF2/tests/frontend/admin-navigation.spec.ts
T

28 lines
978 B
TypeScript

import { decideAdminGuard } from '../../frontend/src/app/core/guards/admin.guard.decision';
describe('decideAdminGuard', () => {
it('redirects to /bootstrap when not initialized', () => {
expect(
decideAdminGuard({ initialized: false, isAuthenticated: true, role: 'admin' }),
).toEqual({ kind: 'redirect', path: '/bootstrap' });
});
it('redirects to /login when not authenticated', () => {
expect(
decideAdminGuard({ initialized: true, isAuthenticated: false, role: undefined }),
).toEqual({ kind: 'redirect', path: '/login' });
});
it('redirects to / when authenticated but not admin', () => {
expect(
decideAdminGuard({ initialized: true, isAuthenticated: true, role: 'player' }),
).toEqual({ kind: 'redirect', path: '/' });
});
it('allows when authenticated admin', () => {
expect(
decideAdminGuard({ initialized: true, isAuthenticated: true, role: 'admin' }),
).toEqual({ kind: 'allow' });
});
});