All files / app/codeCharta/ui/metricChooser filterMetricDataBySearchTerm.pipe.ts

100% Statements 10/10
100% Branches 3/3
100% Functions 2/2
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 248x             8x   34x         34x 60x 60x 8x   60x        
import { Pipe, PipeTransform } from "@angular/core"
import { EdgeMetricData, NodeMetricData } from "../../codeCharta.model"
 
@Pipe({
    name: "filterMetricDataBySearchTerm",
    standalone: true
})
export class FilterMetricDataBySearchTermPipe implements PipeTransform {
    transform(metricData: NodeMetricData[] | EdgeMetricData[], searchTerm: string) {
        const lowerCasedSearchTerm = searchTerm.toLocaleLowerCase()
 
        // after the "formerly mcc" is removed, change this back to the commented out code
        //return metricData.filter(data => data.name.toLocaleLowerCase().includes(lowerCasedSearchTerm))
 
        return metricData.filter(data => {
            let newName = data.name
            if (data.name === "complexity" || data.name === "sonar_complexity") {
                newName += " (formerly mcc)"
            }
            return newName.toLocaleLowerCase().includes(lowerCasedSearchTerm)
        })
    }
}