All files / src/app/shared/classes test-mode.class.ts

90.9% Statements 10/11
80% Branches 4/5
100% Functions 2/2
90.9% Lines 10/11

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 25 26 27 28 29 30 31        36x 36x     36x 36x   36x               36x 36x   36x   432x 432x          
import { TestModeData } from 'testcenter-common/classes/test-mode-data.class';
import { AppError } from '../../app.interfaces';
 
export class TestMode extends TestModeData {
  modeId: keyof typeof TestModeData.modes = 'RUN-DEMO';
  modeLabel: string = 'Demo';
 
  constructor(loginMode: string = 'RUN-DEMO') {
    super();
    const mode: keyof typeof TestModeData.modes = <keyof typeof TestModeData.modes>loginMode.toUpperCase();
 
    Iif (!mode || !TestModeData.modes[mode]) {
      throw new AppError({
        type: 'warning',
        label: 'Unbekannte Nutzerrolle',
        description: `Unbekannte Nutzerrolle: ${mode}.`
      });
    }
 
    this.modeId = mode;
    this.modeLabel = TestModeData.labels[mode];
 
    (Object.keys(this) as Array<keyof typeof TestModeData.modes[typeof mode]>)
      .forEach((key: keyof typeof TestModeData.modes[typeof mode]) => {
        if (key in this) {
          this[key] = TestModeData.modes[mode][key];
        }
      });
  }
}