@@ -24,6 +24,7 @@ const all_versions = [
24
24
const cases = [
25
25
null ,
26
26
"-r=latest" ,
27
+ "-r=7" ,
27
28
"-r=7.2.0" ,
28
29
"-r=v7.2.0" ,
29
30
"-r=v7.2" ,
@@ -49,7 +50,7 @@ const runCli = async (version = null) => {
49
50
( v ) => v !== version && v !== versionFolder ( version )
50
51
) ; //revert process args
51
52
} else {
52
- process . chdir ( prevCwd ) ; //revert process current dir
53
+ process . chdir ( prevCwd ) ; //revert process current dir
53
54
}
54
55
} ;
55
56
describe . each ( cases ) ( "Downloading %s" , ( version ) => {
@@ -111,14 +112,29 @@ describe.each(cases)("Downloading %s", (version) => {
111
112
} ) ;
112
113
113
114
describe ( "Errors" , ( ) => {
114
- test ( "Wrong version 6..2.3" , async ( ) => { //maybe create test.each() for more errors scenarios
115
- const mockExit = jest . spyOn ( process , "exit" ) . mockImplementation ( ( ) => { } ) ;
115
+ test ( "Wrong version 6..2.3" , async ( ) => {
116
+ //maybe create test.each() for more errors scenarios
116
117
const version = "-r=6..2.3" ;
118
+ try {
119
+ await runCli ( version ) ;
120
+ } catch ( err ) {
121
+ expect ( err ) . toBe ( "ETARGET" ) ;
122
+ } finally {
123
+ await fs . remove ( versionFolder ( version ) ) ;
124
+ }
125
+ } ) ;
126
+ } ) ;
117
127
118
- await runCli ( version ) ;
119
-
120
- await fs . remove ( versionFolder ( version ) ) ;
121
- expect ( mockExit ) . toHaveBeenCalledWith ( 1 ) ;
122
- mockExit . mockRestore ( ) ;
128
+ describe ( "Unexpected errors" , ( ) => {
129
+ test ( "Unexpected error 6..2.3,7.2.3" , async ( ) => {
130
+ //maybe create test.each() for more errors scenarios
131
+ const version = "-r=6..2.3,7.2.3" ;
132
+ try {
133
+ await runCli ( version ) ;
134
+ } catch ( err ) {
135
+ expect ( err ) . not . toBe ( "ETARGET" ) ;
136
+ } finally {
137
+ await fs . remove ( versionFolder ( version ) ) ;
138
+ }
123
139
} ) ;
124
140
} ) ;
0 commit comments