All files / app/model profile.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                            70x     1x 1x 2x   1x    
import { Role } from './user';
 
export interface Profile {
  tag: string;
  active?: boolean;
  password?: string;
  role?: string;
}
 
export type ProfilePageArgs = {
  page?: number,
  size?: number,
};
 
const roleOrder: Role[] = ['ROLE_ANONYMOUS', 'ROLE_VIEWER', 'ROLE_USER', 'ROLE_EDITOR', 'ROLE_MOD', 'ROLE_ADMIN', 'ROLE_BANNED'];
 
export function getRole(...roles: (string | undefined)[]) {
  let index = 0;
  for (const r of roles) {
    index = Math.max(index, roleOrder.indexOf(r as any));
  }
  return roleOrder[index];
}