All files / app/components/page-cv/cv-testimonial-rating cv-testimonial-rating.component.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

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                          1x   53x               169x 169x      
import { Component, Input } from '@angular/core';
 
/**
 * Component responsible for displaying a rating with stars. Has a number input,
 * expected to be from 0 to 5, and will display the appropriate amount of stars
 * for that rating. Non integers are supported.
 */
@Component({
  selector: 'app-cv-testimonial-rating',
  templateUrl: './cv-testimonial-rating.component.html',
  styleUrls: ['./cv-testimonial-rating.component.css'],
  standalone: true,
})
export class CvTestimonialRatingComponent {
  /** The rating from 0 to 5. */
  @Input() rating = 5;
 
  /**
   * Get the percentage of stars to be displayed.
   *
   * @returns The percentage
   */
  getPercent() {
    const percent = (this.rating / 5) * 100;
    return percent + '%';
  }
}