@@ -126,7 +126,7 @@ function mockSysInfo(childProcessResult: IChildProcessResults, hostInfoOptions?:
126126 spawnFromEvent : async ( command : string , args : string [ ] , event : string , options : ISpawnFromEventOptions ) => {
127127 return getResultFromChildProcess ( childProcessResultDictionary [ command ] , command , options ) ;
128128 } ,
129- execFile : async ( ) => {
129+ execFile : async ( ) : Promise < any > => {
130130 return undefined ;
131131 }
132132 } ;
@@ -153,7 +153,7 @@ describe("SysInfo unit tests", () => {
153153
154154 beforeEach ( ( ) => {
155155 // We need to mock this because on Mac the tests in which the platform is mocked to Windows in the process there will be no CommonProgramFiles.
156- process . env . CommonProgramFiles = process . env . CommonProgramFiles || "mocked on mac" ;
156+ process . env [ " CommonProgramFiles" ] = process . env [ " CommonProgramFiles" ] || "mocked on mac" ;
157157 process . env [ "CommonProgramFiles(x86)" ] = process . env [ "CommonProgramFiles(x86)" ] || "mocked on mac" ;
158158 } ) ;
159159
@@ -322,6 +322,29 @@ describe("SysInfo unit tests", () => {
322322 } ) ;
323323 } ) ;
324324
325+ describe ( "nativeScriptCliVersion" , ( ) => {
326+ it ( "is null when tns is not installed" , async ( ) => {
327+ childProcessResult . nativeScriptCliVersion = { shouldThrowError : true } ;
328+ sysInfo = mockSysInfo ( childProcessResult , { isWindows : false , isDarwin : true , dotNetVersion : "4.5.1" } ) ;
329+ let result = await sysInfo . getSysInfo ( ) ;
330+ assert . deepEqual ( result . nativeScriptCliVersion , null ) ;
331+ } ) ;
332+
333+ it ( "is correct when the version is the only row in `tns --version` output" , async ( ) => {
334+ childProcessResult . nativeScriptCliVersion = { result : setStdOut ( "3.0.0" ) } ;
335+ sysInfo = mockSysInfo ( childProcessResult , { isWindows : false , isDarwin : true , dotNetVersion : "4.5.1" } ) ;
336+ let result = await sysInfo . getSysInfo ( ) ;
337+ assert . deepEqual ( result . nativeScriptCliVersion , "3.0.0" ) ;
338+ } ) ;
339+
340+ it ( "is correct when there are warnings in the `tns --version` output" , async ( ) => {
341+ childProcessResult . nativeScriptCliVersion = { result : setStdOut ( "Some warning due to invalid extensions\\n3.0.0" ) } ;
342+ sysInfo = mockSysInfo ( childProcessResult , { isWindows : false , isDarwin : true , dotNetVersion : "4.5.1" } ) ;
343+ let result = await sysInfo . getSysInfo ( ) ;
344+ assert . deepEqual ( result . nativeScriptCliVersion , "3.0.0" ) ;
345+ } ) ;
346+ } ) ;
347+
325348 describe ( "returns correct results when exceptions are raised during sysInfo data collection" , ( ) => {
326349 beforeEach ( ( ) => {
327350 childProcessResult = {
0 commit comments