All files / src/app/linqpad-review-pages/validations/services validations-format.service.ts

100% Statements 16/16
83.33% Branches 5/6
100% Functions 3/3
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  1x   1x   1x 4x       1x 1x 1x 1x 1x 1x 1x 1x     1x   1x  
import { IFileInfo } from '../../../model/fileInfo.model';
import { FormatService } from '../../../services/data-service/format.service';
 
export class ValidationsFormatService extends FormatService {
 
  getBadgeColor(metric: number) {
    return metric === 0 ? 'green'
      : metric < 10 ? 'orange' : 'red';
  }
 
  getMetric(tempDiv: HTMLElement): number {
    let total = 0;
    const elementsWithCount = tempDiv.getElementsByClassName('typeheader');
    for (let i = 0; i < elementsWithCount.length; ++i) {
      const countAsString = elementsWithCount[i].innerHTML.substr(1).split(' ')[0];
      const isnum = /^\d+$/.test(countAsString);
      Eif (isnum) {
        total += Number(countAsString);
      }
    }
    return total;
  }
}