All files / src/domain/certificates/useCases generateRevocationReason.ts

100% Statements 8/8
100% Branches 6/6
100% Functions 1/1
100% Lines 8/8

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    108x 108x 108x     108x     19x 19x 19x 19x      
import { getText } from '../../i18n/useCases';
 
export enum CREDENTIAL_STATUS_OPTIONS {
  'REVOKED' = 'revoked',
  'SUSPENDED' = 'suspended'
}
 
const CREDENTIAL_STATUS_PLACEHOLDER = '${CREDENTIAL_STATUS}';
 
export default function generateRevocationReason (reason: string = '', status: CREDENTIAL_STATUS_OPTIONS = CREDENTIAL_STATUS_OPTIONS.REVOKED): string {
  const statusText = getText('revocation', status);
  reason = reason.trim();
  reason = reason.length > 0 ? ` ${getText('revocation', 'preReason')} ${reason}${reason.slice(-1) !== '.' ? '.' : ''}` : '';
  return `${getText('revocation', 'reason')
    .replace(CREDENTIAL_STATUS_PLACEHOLDER, statusText)}${reason}`;
}