All files / src/app/shared/classes booklet-config.class.ts

100% Statements 8/8
100% Branches 1/1
100% Functions 5/5
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 18 19 20 21 22 23 24 25 26        9x   35x 34x           8x 56x     24x 24x       8x      
import { BookletConfigData } from 'testcenter-common/classes/booklet-config-data.class';
 
export class BookletConfig extends BookletConfigData {
  setFromKeyValuePairs(config: { [key: string]: string }): void {
    Object.keys(config)
      .forEach(key => {
        if (key in this) {
          (this as any)[key] = config[key];
        }
      });
  }
 
  setFromXml(bookletConfigElement: Element): void {
    const bookletConfigs = Array.prototype.slice.call(bookletConfigElement.childNodes)
      .filter(e => e.nodeType === 1)
      .reduce(
        (agg, item) => {
          agg[item.getAttribute('key')] = item.textContent;
          return agg;
        },
        {}
      );
    this.setFromKeyValuePairs(bookletConfigs);
  }
}