Files
gridpilot.gg/apps/website/lib/leagueRoles.test.ts
2026-01-01 22:46:59 +01:00

67 lines
2.3 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { isLeagueAdminOrHigherRole, LeagueRoleUtility, LeagueMembershipUtility } from './leagueRoles';
describe('leagueRoles', () => {
describe('isLeagueAdminOrHigherRole', () => {
it('should return true for "owner" role', () => {
expect(isLeagueAdminOrHigherRole('owner')).toBe(true);
});
it('should return true for "admin" role', () => {
expect(isLeagueAdminOrHigherRole('admin')).toBe(true);
});
it('should return true for "steward" role', () => {
expect(isLeagueAdminOrHigherRole('steward')).toBe(true);
});
it('should return false for "member" role', () => {
expect(isLeagueAdminOrHigherRole('member')).toBe(false);
});
it('should return false for "viewer" role', () => {
expect(isLeagueAdminOrHigherRole('viewer')).toBe(false);
});
it('should return false for empty string', () => {
expect(isLeagueAdminOrHigherRole('')).toBe(false);
});
it('should return false for unknown roles', () => {
expect(isLeagueAdminOrHigherRole('unknown')).toBe(false);
expect(isLeagueAdminOrHigherRole('moderator')).toBe(false);
});
it('should be case-sensitive', () => {
expect(isLeagueAdminOrHigherRole('OWNER')).toBe(false);
expect(isLeagueAdminOrHigherRole('Admin')).toBe(false);
expect(isLeagueAdminOrHigherRole('STEWARD')).toBe(false);
});
});
describe('LeagueRoleUtility re-export', () => {
it('should be exported', () => {
expect(LeagueRoleUtility).toBeDefined();
});
it('should be a class', () => {
// This verifies that the re-export works correctly
// The actual functionality is tested in the utility's own test file
expect(typeof LeagueRoleUtility).toBe('function');
expect(LeagueRoleUtility.prototype).toBeDefined();
});
});
describe('LeagueMembershipUtility re-export', () => {
it('should be exported', () => {
expect(LeagueMembershipUtility).toBeDefined();
});
it('should be a class', () => {
// This verifies that the re-export works correctly
// The actual functionality is tested in the utility's own test file
expect(typeof LeagueMembershipUtility).toBe('function');
expect(LeagueMembershipUtility.prototype).toBeDefined();
});
});
});