@@ -55,6 +55,7 @@ describe("RuntimeInfo", () => {
55
55
describe ( "environment()" , ( ) => {
56
56
let spawnSyncStub ;
57
57
let logErrorStub ;
58
+ let processVersionStub ;
58
59
let originalProcessArgv ;
59
60
let spawnSyncStubArgs ;
60
61
const originalOsPlatform = os . platform ;
@@ -65,10 +66,12 @@ describe("RuntimeInfo", () => {
65
66
os . release = ( ) => "20.3.0" ;
66
67
spawnSyncStub = sinon . stub ( spawn , "sync" ) ;
67
68
logErrorStub = sinon . stub ( log , "error" ) ;
69
+ processVersionStub = sinon
70
+ . stub ( process , "version" )
71
+ . value ( "v12.8.0" ) ;
68
72
originalProcessArgv = process . argv ;
69
73
process . argv [ 1 ] = LOCAL_ESLINT_BIN_PATH ;
70
74
spawnSyncStubArgs = [
71
- "v12.8.0" ,
72
75
"6.11.3" ,
73
76
unIndent `
74
77
{
@@ -99,6 +102,7 @@ describe("RuntimeInfo", () => {
99
102
afterEach ( ( ) => {
100
103
spawnSyncStub . restore ( ) ;
101
104
logErrorStub . restore ( ) ;
105
+ processVersionStub . restore ( ) ;
102
106
process . argv = originalProcessArgv ;
103
107
os . platform = originalOsPlatform ;
104
108
os . release = originalOsRelease ;
@@ -141,7 +145,7 @@ describe("RuntimeInfo", () => {
141
145
142
146
it ( "should return a string containing environment information when not installed locally" , ( ) => {
143
147
spawnSyncStubArgs . splice (
144
- 2 ,
148
+ 1 ,
145
149
2 ,
146
150
unIndent `
147
151
{
@@ -169,7 +173,7 @@ describe("RuntimeInfo", () => {
169
173
} ) ;
170
174
171
175
it ( "should return a string containing environment information when not installed globally" , ( ) => {
172
- spawnSyncStubArgs [ 4 ] = "{}" ;
176
+ spawnSyncStubArgs [ 3 ] = "{}" ;
173
177
setupSpawnSyncStubReturnVals ( spawnSyncStub , spawnSyncStubArgs ) ;
174
178
175
179
assert . strictEqual (
@@ -189,7 +193,7 @@ describe("RuntimeInfo", () => {
189
193
it ( "log and throw an error when npm version can not be found" , ( ) => {
190
194
const expectedErr = new Error ( "npm can not be found" ) ;
191
195
192
- spawnSyncStubArgs [ 1 ] = expectedErr ;
196
+ spawnSyncStubArgs [ 0 ] = expectedErr ;
193
197
setupSpawnSyncStubReturnVals ( spawnSyncStub , spawnSyncStubArgs ) ;
194
198
195
199
assert . throws ( RuntimeInfo . environment , expectedErr ) ;
@@ -202,7 +206,7 @@ describe("RuntimeInfo", () => {
202
206
it ( "log and throw an error when npm binary path can not be found" , ( ) => {
203
207
const expectedErr = new Error ( "npm can not be found" ) ;
204
208
205
- spawnSyncStubArgs [ 3 ] = expectedErr ;
209
+ spawnSyncStubArgs [ 2 ] = expectedErr ;
206
210
setupSpawnSyncStubReturnVals ( spawnSyncStub , spawnSyncStubArgs ) ;
207
211
208
212
assert . throws ( RuntimeInfo . environment , expectedErr ) ;
@@ -213,7 +217,7 @@ describe("RuntimeInfo", () => {
213
217
} ) ;
214
218
215
219
it ( "log and throw an error when checking for local ESLint version when returned output of command is malformed" , ( ) => {
216
- spawnSyncStubArgs [ 2 ] = "This is not JSON" ;
220
+ spawnSyncStubArgs [ 1 ] = "This is not JSON" ;
217
221
setupSpawnSyncStubReturnVals ( spawnSyncStub , spawnSyncStubArgs ) ;
218
222
219
223
assert . throws (
@@ -227,7 +231,7 @@ describe("RuntimeInfo", () => {
227
231
} ) ;
228
232
229
233
it ( "log and throw an error when checking for global ESLint version when returned output of command is malformed" , ( ) => {
230
- spawnSyncStubArgs [ 4 ] = "This is not JSON" ;
234
+ spawnSyncStubArgs [ 3 ] = "This is not JSON" ;
231
235
setupSpawnSyncStubReturnVals ( spawnSyncStub , spawnSyncStubArgs ) ;
232
236
233
237
assert . throws (
0 commit comments