File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
packages/utils/src/lib/reports Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import type {
1717} from './types.js' ;
1818
1919export function scoreFilter < T extends { score : number } > (
20- options : ScoreFilter | undefined ,
20+ options ? : ScoreFilter ,
2121) {
2222 const { isScoreListed = ( ) => true } = options ?? { } ;
2323 return ( { score } : T ) => isScoreListed ( score ) ;
Original file line number Diff line number Diff line change @@ -26,11 +26,24 @@ import {
2626 formatValueChange ,
2727 getPluginNameFromSlug ,
2828 roundValue ,
29+ scoreFilter ,
2930 scoreMarker ,
3031 severityMarker ,
3132 targetScoreIcon ,
3233} from './utils.js' ;
3334
35+ describe ( 'scoreFilter' , ( ) => {
36+ it ( 'should not filter by score if no options are passed' , ( ) => {
37+ expect ( scoreFilter ( ) ( { score : 0 } ) ) . toBe ( true ) ;
38+ } ) ;
39+
40+ it ( 'should filter by score if options are passed' , ( ) => {
41+ expect (
42+ scoreFilter ( { isScoreListed : score => score === 0.5 } ) ( { score : 0 } ) ,
43+ ) . toBe ( false ) ;
44+ } ) ;
45+ } ) ;
46+
3447describe ( 'formatReportScore' , ( ) => {
3548 it . each ( [
3649 [ 0 , '0' ] ,
You can’t perform that action at this time.
0 commit comments