@@ -20,56 +20,25 @@ function createUpgradeContext(version: string) {
2020}
2121
2222describe ( 'checkUpgrade' , ( ) => {
23- it ( 'should flag when latest is greater than current version' , async ( ) => {
24- const ctx = createUpgradeContext ( '^1.0.0' )
25- const result = await checkUpgrade ( ctx )
23+ it ( 'should create upgrade diagnostic payload' , async ( ) => {
24+ const result = await checkUpgrade ( createUpgradeContext ( '^1.0.0' ) )
2625
2726 expect ( result ) . toBeDefined ( )
2827 expect ( result ! . code ) . toMatchObject ( { value : 'upgrade' } )
29- expect ( result ! . message ) . toContain ( ' 2.7.0')
28+ expect ( result ! . message ) . toMatchInlineSnapshot ( '"New version available: ^ 2.7.0" ')
3029 } )
3130
32- it ( 'should not flag when already on latest' , async ( ) => {
33- const ctx = createUpgradeContext ( '^2.7.0' )
34- const result = await checkUpgrade ( ctx )
35-
36- expect ( result ) . toBeUndefined ( )
37- } )
38-
39- it ( 'should not flag when version is a dist tag' , async ( ) => {
40- const ctx = createUpgradeContext ( 'latest' )
41- const result = await checkUpgrade ( ctx )
42-
43- expect ( result ) . toBeUndefined ( )
44- } )
45-
46- it ( 'should not flag when version is a dist tag with protocol' , async ( ) => {
47- const ctx = createUpgradeContext ( 'npm:latest' )
48- const result = await checkUpgrade ( ctx )
49-
50- expect ( result ) . toBeUndefined ( )
51- } )
52-
53- it ( 'should flag prerelease upgrade within same pre-id' , async ( ) => {
54- const ctx = createUpgradeContext ( '3.0.0-alpha.1' )
55- const result = await checkUpgrade ( ctx )
31+ it ( 'should preserve protocol prefix in diagnostic message' , async ( ) => {
32+ const result = await checkUpgrade ( createUpgradeContext ( 'npm:^1.0.0' ) )
5633
5734 expect ( result ) . toBeDefined ( )
58- expect ( result ! . message ) . toContain ( '3.0.0-alpha.5' )
35+ expect ( result ! . code ) . toMatchObject ( { value : 'upgrade' } )
36+ expect ( result ! . message ) . toMatchInlineSnapshot ( '"New version available: npm:^2.7.0"' )
5937 } )
6038
61- it ( 'should not flag prerelease when already on latest pre-id version' , async ( ) => {
62- const ctx = createUpgradeContext ( '3.0.0-alpha.5' )
63- const result = await checkUpgrade ( ctx )
39+ it ( 'should return undefined for unsupported protocol' , async ( ) => {
40+ const result = await checkUpgrade ( createUpgradeContext ( 'workspace:^1.0.0' ) )
6441
6542 expect ( result ) . toBeUndefined ( )
6643 } )
67-
68- it ( 'should preserve protocol prefix in message' , async ( ) => {
69- const ctx = createUpgradeContext ( 'npm:^1.0.0' )
70- const result = await checkUpgrade ( ctx )
71-
72- expect ( result ) . toBeDefined ( )
73- expect ( result ! . message ) . toContain ( 'npm:^2.7.0' )
74- } )
7544} )
0 commit comments