@@ -84,7 +84,7 @@ describe('useInstallSizeDiff', () => {
8484 expect ( comparisonVersion . value ) . toBe ( '1.0.0' )
8585 } )
8686
87- it ( 'uses the latest dist-tag for a prerelease version' , ( ) => {
87+ it ( 'compares a prerelease against the previous stable version' , ( ) => {
8888 const pkg = createPackage (
8989 'test' ,
9090 { '1.0.0' : '2020-01-01' , '2.0.0-beta.1' : '2021-01-01' } ,
@@ -95,20 +95,28 @@ describe('useInstallSizeDiff', () => {
9595 expect ( comparisonVersion . value ) . toBe ( '1.0.0' )
9696 } )
9797
98- it ( 'returns null when the prerelease version is already latest' , ( ) => {
98+ it ( 'compares an old prerelease against the stable version before it, not latest' , ( ) => {
9999 const pkg = createPackage (
100100 'test' ,
101- { '2.0.0-beta.1' : '2021-01-01' } ,
102- { latest : '2.0.0-beta.1' } ,
101+ {
102+ '1.16.0' : '2024-01-01' ,
103+ '1.17.0-alpha.0' : '2024-02-01' ,
104+ '1.18.0' : '2024-03-01' ,
105+ '1.50.0' : '2025-01-01' ,
106+ } ,
107+ { latest : '1.50.0' } ,
103108 )
104109
105- const { comparisonVersion } = useInstallSizeDiff ( 'test' , '2.0 .0-beta.1 ' , pkg , null )
106- expect ( comparisonVersion . value ) . toBeNull ( )
110+ const { comparisonVersion } = useInstallSizeDiff ( 'test' , '1.17 .0-alpha.0 ' , pkg , null )
111+ expect ( comparisonVersion . value ) . toBe ( '1.16.0' )
107112 } )
108113
109- it ( 'returns null for a prerelease when there is no latest tag' , ( ) => {
110- const pkg = createPackage ( 'test' , { '2.0.0-beta.1' : '2021-01-01' } , { } )
111- pkg [ 'dist-tags' ] = { }
114+ it ( 'returns null for a prerelease with no prior stable versions' , ( ) => {
115+ const pkg = createPackage (
116+ 'test' ,
117+ { '2.0.0-beta.1' : '2021-01-01' } ,
118+ { latest : '2.0.0-beta.1' } ,
119+ )
112120
113121 const { comparisonVersion } = useInstallSizeDiff ( 'test' , '2.0.0-beta.1' , pkg , null )
114122 expect ( comparisonVersion . value ) . toBeNull ( )
0 commit comments