@@ -20,8 +20,14 @@ it('returns new thresholds if coverages are higher', () => {
2020 statements : { pct : 50 } ,
2121 }
2222 const margin = 0
23+ const tolerance = 0
2324
24- const newThresholds = getNewThresholds ( thresholds , coverages , margin )
25+ const newThresholds = getNewThresholds (
26+ thresholds ,
27+ coverages ,
28+ margin ,
29+ tolerance ,
30+ )
2531
2632 expect ( newThresholds ) . toStrictEqual ( {
2733 branches : { diff : 70 , next : 80 , prev : 10 } ,
@@ -45,11 +51,74 @@ it('only returns new thresholds if coverages are above the margin', () => {
4551 statements : { pct : 50 } ,
4652 }
4753 const margin = 50
54+ const tolerance = 0
4855
49- const newThresholds = getNewThresholds ( thresholds , coverages , margin )
56+ const newThresholds = getNewThresholds (
57+ thresholds ,
58+ coverages ,
59+ margin ,
60+ tolerance ,
61+ )
5062
5163 expect ( newThresholds ) . toStrictEqual ( {
5264 branches : { diff : 70 , next : 80 , prev : 10 } ,
5365 functions : { diff : 50 , next : 70 , prev : 20 } ,
5466 } )
5567} )
68+
69+ it ( 'should return new thresholds if coverage - tolerance is higher than the current threshold' , ( ) => {
70+ const thresholds = {
71+ branches : 10 ,
72+ functions : 20 ,
73+ lines : 30 ,
74+ statements : 40 ,
75+ }
76+ const coverages = {
77+ branches : { pct : 80 } ,
78+ functions : { pct : 70 } ,
79+ lines : { pct : 60 } ,
80+ statements : { pct : 50 } ,
81+ }
82+ const margin = 0
83+ const tolerance = 10
84+
85+ const newThresholds = getNewThresholds (
86+ thresholds ,
87+ coverages ,
88+ margin ,
89+ tolerance ,
90+ )
91+
92+ expect ( newThresholds ) . toStrictEqual ( {
93+ branches : { diff : 60 , next : 70 , prev : 10 } ,
94+ functions : { diff : 40 , next : 60 , prev : 20 } ,
95+ lines : { diff : 20 , next : 50 , prev : 30 } ,
96+ statements : { diff : 0 , next : 40 , prev : 40 } ,
97+ } )
98+ } )
99+
100+ it ( 'should not return new thresholds if coverage - tolerance is lower than the current threshold' , ( ) => {
101+ const thresholds = {
102+ branches : 10 ,
103+ functions : 20 ,
104+ lines : 30 ,
105+ statements : 40 ,
106+ }
107+ const coverages = {
108+ branches : { pct : 80 } ,
109+ functions : { pct : 70 } ,
110+ lines : { pct : 60 } ,
111+ statements : { pct : 50 } ,
112+ }
113+ const margin = 0
114+ const tolerance = 100
115+
116+ const newThresholds = getNewThresholds (
117+ thresholds ,
118+ coverages ,
119+ margin ,
120+ tolerance ,
121+ )
122+
123+ expect ( newThresholds ) . toStrictEqual ( { } )
124+ } )
0 commit comments