@@ -160,6 +160,34 @@ describe('Unit: Commands > Install', function () {
160
160
} ) ;
161
161
} ) ;
162
162
163
+ it ( 'normalizes version to a string' , function ( ) {
164
+ const dirEmptyStub = sinon . stub ( ) . returns ( true ) ;
165
+ const listrStub = sinon . stub ( ) ;
166
+ listrStub . onFirstCall ( ) . resolves ( ) ;
167
+ listrStub . onSecondCall ( ) . rejects ( ) ;
168
+ const setEnvironmentStub = sinon . stub ( ) ;
169
+
170
+ const InstallCommand = proxyquire ( modulePath , {
171
+ '../utils/dir-is-empty' : dirEmptyStub
172
+ } ) ;
173
+ const testInstance = new InstallCommand ( { listr : listrStub } , { cliVersion : '1.0.0' , setEnvironment : setEnvironmentStub } ) ;
174
+ const runCommandStub = sinon . stub ( testInstance , 'runCommand' ) . resolves ( ) ;
175
+
176
+ return testInstance . run ( { version : 2 , zip : '' , v1 : false , _ : [ 'install' , 'local' ] } ) . then ( ( ) => {
177
+ expect ( false , 'run should have rejected' ) . to . be . true ;
178
+ } ) . catch ( ( ) => {
179
+ expect ( dirEmptyStub . calledOnce ) . to . be . true ;
180
+ expect ( runCommandStub . calledOnce ) . to . be . true ;
181
+ expect ( listrStub . calledOnce ) . to . be . true ;
182
+ expect ( listrStub . args [ 0 ] [ 1 ] ) . to . deep . equal ( {
183
+ argv : { version : '2' , zip : '' , v1 : false , _ : [ 'install' , 'local' ] } ,
184
+ cliVersion : '1.0.0'
185
+ } ) ;
186
+ expect ( setEnvironmentStub . calledOnce ) . to . be . true ;
187
+ expect ( setEnvironmentStub . calledWithExactly ( true , true ) ) . to . be . true ;
188
+ } ) ;
189
+ } ) ;
190
+
163
191
it ( 'calls all tasks and returns after tasks run if --no-setup is passed' , function ( ) {
164
192
const dirEmptyStub = sinon . stub ( ) . returns ( true ) ;
165
193
const yarnInstallStub = sinon . stub ( ) . resolves ( ) ;
0 commit comments