@@ -61,8 +61,19 @@ describe('useInstallSizeDiff', () => {
6161 expect ( comparisonVersion . value ) . toBeNull ( )
6262 } )
6363
64+ it ( 'returns null for the second stable version (no baseline for first)' , ( ) => {
65+ const pkg = createPackage ( 'test' , {
66+ '1.0.0' : '2020-01-01' ,
67+ '1.1.0' : '2021-01-01' ,
68+ } )
69+
70+ const { comparisonVersion } = useInstallSizeDiff ( 'test' , '1.1.0' , pkg , null )
71+ expect ( comparisonVersion . value ) . toBeNull ( )
72+ } )
73+
6474 it ( 'skips prerelease versions when finding previous stable' , ( ) => {
6575 const pkg = createPackage ( 'test' , {
76+ '0.9.0' : '2019-01-01' ,
6677 '1.0.0' : '2020-01-01' ,
6778 '2.0.0-beta.1' : '2021-01-01' ,
6879 '2.0.0-beta.2' : '2021-06-01' ,
@@ -117,6 +128,7 @@ describe('useInstallSizeDiff', () => {
117128
118129 it ( 'returns null when both thresholds are not met' , async ( ) => {
119130 const pkg = createPackage ( 'pkg-no-threshold' , {
131+ '0.9.0' : '2019-01-01' ,
120132 '1.0.0' : '2020-01-01' ,
121133 '1.1.0' : '2021-01-01' ,
122134 } )
@@ -140,7 +152,11 @@ describe('useInstallSizeDiff', () => {
140152 } )
141153
142154 it ( 'sets sizeThresholdExceeded when size increased by more than 25%' , async ( ) => {
143- const pkg = createPackage ( 'pkg-size-only' , { '1.0.0' : '2020-01-01' , '1.1.0' : '2021-01-01' } )
155+ const pkg = createPackage ( 'pkg-size-only' , {
156+ '0.9.0' : '2019-01-01' ,
157+ '1.0.0' : '2020-01-01' ,
158+ '1.1.0' : '2021-01-01' ,
159+ } )
144160 const current = createInstallSize ( 'pkg-size-only' , {
145161 version : '1.1.0' ,
146162 totalSize : 7000 ,
@@ -172,7 +188,11 @@ describe('useInstallSizeDiff', () => {
172188 } )
173189
174190 it ( 'sets depThresholdExceeded when more than 5 dependencies were added' , async ( ) => {
175- const pkg = createPackage ( 'pkg-deps-only' , { '1.0.0' : '2020-01-01' , '1.1.0' : '2021-01-01' } )
191+ const pkg = createPackage ( 'pkg-deps-only' , {
192+ '0.9.0' : '2019-01-01' ,
193+ '1.0.0' : '2020-01-01' ,
194+ '1.1.0' : '2021-01-01' ,
195+ } )
176196 const current = createInstallSize ( 'pkg-deps-only' , {
177197 version : '1.1.0' ,
178198 totalSize : 5100 ,
@@ -204,7 +224,11 @@ describe('useInstallSizeDiff', () => {
204224 } )
205225
206226 it ( 'returns correct diff values' , async ( ) => {
207- const pkg = createPackage ( 'pkg-both' , { '1.0.0' : '2020-01-01' , '1.1.0' : '2021-01-01' } )
227+ const pkg = createPackage ( 'pkg-both' , {
228+ '0.9.0' : '2019-01-01' ,
229+ '1.0.0' : '2020-01-01' ,
230+ '1.1.0' : '2021-01-01' ,
231+ } )
208232 const current = createInstallSize ( 'pkg-both' , {
209233 version : '1.1.0' ,
210234 totalSize : 10000 ,
@@ -234,7 +258,11 @@ describe('useInstallSizeDiff', () => {
234258
235259 describe ( 'fetch behavior' , ( ) => {
236260 it ( 'calls the correct API endpoint for the comparison version' , async ( ) => {
237- const pkg = createPackage ( 'my-pkg' , { '1.0.0' : '2020-01-01' , '1.1.0' : '2021-01-01' } )
261+ const pkg = createPackage ( 'my-pkg' , {
262+ '0.9.0' : '2019-01-01' ,
263+ '1.0.0' : '2020-01-01' ,
264+ '1.1.0' : '2021-01-01' ,
265+ } )
238266 const current = createInstallSize ( 'my-pkg' , { version : '1.1.0' , totalSize : 7000 } )
239267 fetchSpy . mockResolvedValue ( createInstallSize ( 'my-pkg' , { version : '1.0.0' , totalSize : 5000 } ) )
240268
0 commit comments