Skip to content

Commit 93d941a

Browse files
committed
Comply with new vitest eslint rule
1 parent dcb6311 commit 93d941a

14 files changed

+170
-133
lines changed

src/command.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('#start()', () => {
101101
command.start();
102102

103103
expect(spawn).toHaveBeenCalledTimes(1);
104-
expect(spawn).toHaveBeenCalledWith(command.command, { detached: true });
104+
expect(spawn).toHaveBeenCalledExactlyOnceWith(command.command, { detached: true });
105105
});
106106

107107
it('sets stdin, process and PID', () => {
@@ -319,7 +319,7 @@ describe('#start()', () => {
319319

320320
const onSent = vi.fn();
321321
command.messages.outgoing.next({ message: {}, onSent });
322-
expect(onSent).toHaveBeenCalledWith(expect.any(Error));
322+
expect(onSent).toHaveBeenCalledExactlyOnceWith(expect.any(Error));
323323
});
324324

325325
it('sends the message to the process', () => {
@@ -379,11 +379,11 @@ describe('#start()', () => {
379379
expect(onSent).not.toHaveBeenCalled();
380380

381381
sendMessage.mock.calls[0][3]();
382-
expect(onSent).toHaveBeenCalledWith(undefined);
382+
expect(onSent).toHaveBeenCalledExactlyOnceWith(undefined);
383383

384384
const error = new Error('test');
385385
sendMessage.mock.calls[0][3](error);
386-
expect(onSent).toHaveBeenCalledWith(error);
386+
expect(onSent).toHaveBeenCalledExactlyOnceWith(error);
387387
});
388388
});
389389
});
@@ -448,15 +448,15 @@ describe('#kill()', () => {
448448
createdCommand.command.kill();
449449

450450
expect(killProcess).toHaveBeenCalledTimes(1);
451-
expect(killProcess).toHaveBeenCalledWith(createdCommand.command.pid, undefined);
451+
expect(killProcess).toHaveBeenCalledExactlyOnceWith(createdCommand.command.pid, undefined);
452452
});
453453

454454
it('kills process with some signal', () => {
455455
createdCommand.command.start();
456456
createdCommand.command.kill('SIGKILL');
457457

458458
expect(killProcess).toHaveBeenCalledTimes(1);
459-
expect(killProcess).toHaveBeenCalledWith(createdCommand.command.pid, 'SIGKILL');
459+
expect(killProcess).toHaveBeenCalledExactlyOnceWith(createdCommand.command.pid, 'SIGKILL');
460460
});
461461

462462
it('does not try to kill inexistent process', () => {

src/concurrently.spec.ts

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ it('fails if no commands were provided', () => {
5050
it('spawns all commands', () => {
5151
create(['echo', 'kill']);
5252
expect(spawn).toHaveBeenCalledTimes(2);
53-
expect(spawn).toHaveBeenCalledWith('echo', expect.objectContaining({}));
54-
expect(spawn).toHaveBeenCalledWith('kill', expect.objectContaining({}));
53+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo', expect.objectContaining({}));
54+
expect(spawn).toHaveBeenCalledExactlyOnceWith('kill', expect.objectContaining({}));
5555
});
5656

5757
it('log output is passed to output stream if logger is specified in options', () => {
@@ -61,8 +61,8 @@ it('log output is passed to output stream if logger is specified in options', ()
6161
logger.log('foo', 'bar');
6262

6363
expect(outputStream.write).toHaveBeenCalledTimes(2);
64-
expect(outputStream.write).toHaveBeenCalledWith('foo');
65-
expect(outputStream.write).toHaveBeenCalledWith('bar');
64+
expect(outputStream.write).toHaveBeenCalledExactlyOnceWith('foo');
65+
expect(outputStream.write).toHaveBeenCalledExactlyOnceWith('bar');
6666
});
6767

6868
it('log output is not passed to output stream after it has errored', () => {
@@ -80,17 +80,17 @@ it('log output is not passed to output stream after it has errored', () => {
8080
it('spawns commands up to configured limit at once', () => {
8181
create(['foo', 'bar', 'baz', 'qux'], { maxProcesses: 2 });
8282
expect(spawn).toHaveBeenCalledTimes(2);
83-
expect(spawn).toHaveBeenCalledWith('foo', expect.objectContaining({}));
84-
expect(spawn).toHaveBeenCalledWith('bar', expect.objectContaining({}));
83+
expect(spawn).toHaveBeenCalledExactlyOnceWith('foo', expect.objectContaining({}));
84+
expect(spawn).toHaveBeenCalledExactlyOnceWith('bar', expect.objectContaining({}));
8585

8686
// Test out of order completion picking up new processes in-order
8787
processes[1].emit('close', 1, null);
8888
expect(spawn).toHaveBeenCalledTimes(3);
89-
expect(spawn).toHaveBeenCalledWith('baz', expect.objectContaining({}));
89+
expect(spawn).toHaveBeenCalledExactlyOnceWith('baz', expect.objectContaining({}));
9090

9191
processes[0].emit('close', null, 'SIGINT');
9292
expect(spawn).toHaveBeenCalledTimes(4);
93-
expect(spawn).toHaveBeenCalledWith('qux', expect.objectContaining({}));
93+
expect(spawn).toHaveBeenCalledExactlyOnceWith('qux', expect.objectContaining({}));
9494

9595
// Shouldn't attempt to spawn anything else.
9696
processes[2].emit('close', 1, null);
@@ -112,18 +112,18 @@ it('spawns commands up to percent based limit at once', () => {
112112

113113
// Max parallel processes should be 2 (50% of 4 cores)
114114
expect(spawn).toHaveBeenCalledTimes(2);
115-
expect(spawn).toHaveBeenCalledWith('foo', expect.objectContaining({}));
116-
expect(spawn).toHaveBeenCalledWith('bar', expect.objectContaining({}));
115+
expect(spawn).toHaveBeenCalledExactlyOnceWith('foo', expect.objectContaining({}));
116+
expect(spawn).toHaveBeenCalledExactlyOnceWith('bar', expect.objectContaining({}));
117117

118118
// Close first process and expect third to be spawned
119119
processes[0].emit('close', 1, null);
120120
expect(spawn).toHaveBeenCalledTimes(3);
121-
expect(spawn).toHaveBeenCalledWith('baz', expect.objectContaining({}));
121+
expect(spawn).toHaveBeenCalledExactlyOnceWith('baz', expect.objectContaining({}));
122122

123123
// Close second process and expect fourth to be spawned
124124
processes[1].emit('close', 1, null);
125125
expect(spawn).toHaveBeenCalledTimes(4);
126-
expect(spawn).toHaveBeenCalledWith('qux', expect.objectContaining({}));
126+
expect(spawn).toHaveBeenCalledExactlyOnceWith('qux', expect.objectContaining({}));
127127
});
128128

129129
it('does not spawn further commands on abort signal aborted', () => {
@@ -140,7 +140,7 @@ it('runs controllers with the commands', () => {
140140
create(['echo', '"echo wrapped"']);
141141

142142
controllers.forEach((controller) => {
143-
expect(controller.handle).toHaveBeenCalledWith([
143+
expect(controller.handle).toHaveBeenCalledExactlyOnceWith([
144144
expect.objectContaining({ command: 'echo', index: 0 }),
145145
expect.objectContaining({ command: 'echo wrapped', index: 1 }),
146146
]);
@@ -151,7 +151,7 @@ it('runs commands with a name or prefix color', () => {
151151
create([{ command: 'echo', prefixColor: 'red', name: 'foo' }, 'kill']);
152152

153153
controllers.forEach((controller) => {
154-
expect(controller.handle).toHaveBeenCalledWith([
154+
expect(controller.handle).toHaveBeenCalledExactlyOnceWith([
155155
expect.objectContaining({ command: 'echo', index: 0, name: 'foo', prefixColor: 'red' }),
156156
expect.objectContaining({ command: 'kill', index: 1, name: '', prefixColor: '' }),
157157
]);
@@ -164,7 +164,7 @@ it('runs commands with a list of colors', () => {
164164
});
165165

166166
controllers.forEach((controller) => {
167-
expect(controller.handle).toHaveBeenCalledWith([
167+
expect(controller.handle).toHaveBeenCalledExactlyOnceWith([
168168
expect.objectContaining({ command: 'echo', prefixColor: 'red' }),
169169
expect.objectContaining({ command: 'kill', prefixColor: 'red' }),
170170
]);
@@ -177,11 +177,11 @@ it('passes commands wrapped from a controller to the next one', () => {
177177

178178
create(['echo']);
179179

180-
expect(controllers[0].handle).toHaveBeenCalledWith([
180+
expect(controllers[0].handle).toHaveBeenCalledExactlyOnceWith([
181181
expect.objectContaining({ command: 'echo', index: 0 }),
182182
]);
183183

184-
expect(controllers[1].handle).toHaveBeenCalledWith([fakeCommand]);
184+
expect(controllers[1].handle).toHaveBeenCalledExactlyOnceWith([fakeCommand]);
185185

186186
expect(fakeCommand.start).toHaveBeenCalledTimes(1);
187187
});
@@ -194,19 +194,19 @@ it('merges extra env vars into each command', () => {
194194
]);
195195

196196
expect(spawn).toHaveBeenCalledTimes(3);
197-
expect(spawn).toHaveBeenCalledWith(
197+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
198198
'echo',
199199
expect.objectContaining({
200200
env: expect.objectContaining({ foo: 'bar' }),
201201
}),
202202
);
203-
expect(spawn).toHaveBeenCalledWith(
203+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
204204
'echo',
205205
expect.objectContaining({
206206
env: expect.objectContaining({ foo: 'baz' }),
207207
}),
208208
);
209-
expect(spawn).toHaveBeenCalledWith(
209+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
210210
'kill',
211211
expect.objectContaining({
212212
env: expect.not.objectContaining({ foo: expect.anything() }),
@@ -227,21 +227,21 @@ it('uses cwd from options for each command', () => {
227227
);
228228

229229
expect(spawn).toHaveBeenCalledTimes(3);
230-
expect(spawn).toHaveBeenCalledWith(
230+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
231231
'echo',
232232
expect.objectContaining({
233233
env: expect.objectContaining({ foo: 'bar' }),
234234
cwd: 'foobar',
235235
}),
236236
);
237-
expect(spawn).toHaveBeenCalledWith(
237+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
238238
'echo',
239239
expect.objectContaining({
240240
env: expect.objectContaining({ foo: 'baz' }),
241241
cwd: 'foobar',
242242
}),
243243
);
244-
expect(spawn).toHaveBeenCalledWith(
244+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
245245
'kill',
246246
expect.objectContaining({
247247
env: expect.not.objectContaining({ foo: expect.anything() }),
@@ -262,14 +262,14 @@ it('uses overridden cwd option for each command if specified', () => {
262262
);
263263

264264
expect(spawn).toHaveBeenCalledTimes(2);
265-
expect(spawn).toHaveBeenCalledWith(
265+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
266266
'echo',
267267
expect.objectContaining({
268268
env: expect.objectContaining({ foo: 'bar' }),
269269
cwd: 'baz',
270270
}),
271271
);
272-
expect(spawn).toHaveBeenCalledWith(
272+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
273273
'echo',
274274
expect.objectContaining({
275275
env: expect.objectContaining({ foo: 'baz' }),
@@ -284,13 +284,13 @@ it('uses raw from options for each command', () => {
284284
});
285285

286286
expect(spawn).toHaveBeenCalledTimes(2);
287-
expect(spawn).toHaveBeenCalledWith(
287+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
288288
'echo',
289289
expect.objectContaining({
290290
stdio: ['inherit', 'inherit', 'inherit'],
291291
}),
292292
);
293-
expect(spawn).toHaveBeenCalledWith(
293+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
294294
'kill',
295295
expect.objectContaining({
296296
stdio: ['inherit', 'inherit', 'inherit'],
@@ -304,13 +304,13 @@ it('uses overridden raw option for each command if specified', () => {
304304
});
305305

306306
expect(spawn).toHaveBeenCalledTimes(2);
307-
expect(spawn).toHaveBeenCalledWith(
307+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
308308
'echo',
309309
expect.objectContaining({
310310
stdio: ['pipe', 'pipe', 'pipe'],
311311
}),
312312
);
313-
expect(spawn).toHaveBeenCalledWith(
313+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
314314
'echo',
315315
expect.objectContaining({
316316
stdio: ['inherit', 'inherit', 'inherit'],
@@ -324,13 +324,13 @@ it('uses hide from options for each command', () => {
324324
});
325325

326326
expect(spawn).toHaveBeenCalledTimes(2);
327-
expect(spawn).toHaveBeenCalledWith(
327+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
328328
'echo',
329329
expect.objectContaining({
330330
stdio: ['pipe', 'pipe', 'pipe'],
331331
}),
332332
);
333-
expect(spawn).toHaveBeenCalledWith(
333+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
334334
'kill',
335335
expect.objectContaining({
336336
stdio: ['pipe', 'ignore', 'ignore'],
@@ -345,13 +345,13 @@ it('hides output for commands even if raw option is on', () => {
345345
});
346346

347347
expect(spawn).toHaveBeenCalledTimes(2);
348-
expect(spawn).toHaveBeenCalledWith(
348+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
349349
'echo',
350350
expect.objectContaining({
351351
stdio: ['inherit', 'inherit', 'inherit'],
352352
}),
353353
);
354-
expect(spawn).toHaveBeenCalledWith(
354+
expect(spawn).toHaveBeenCalledExactlyOnceWith(
355355
'kill',
356356
expect.objectContaining({
357357
stdio: ['pipe', 'ignore', 'ignore'],
@@ -373,10 +373,10 @@ it('argument placeholders are properly replaced when additional arguments are pa
373373
);
374374

375375
expect(spawn).toHaveBeenCalledTimes(4);
376-
expect(spawn).toHaveBeenCalledWith('echo foo', expect.objectContaining({}));
377-
expect(spawn).toHaveBeenCalledWith('echo foo bar', expect.objectContaining({}));
378-
expect(spawn).toHaveBeenCalledWith("echo 'foo bar'", expect.objectContaining({}));
379-
expect(spawn).toHaveBeenCalledWith('echo {@}', expect.objectContaining({}));
376+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo foo', expect.objectContaining({}));
377+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo foo bar', expect.objectContaining({}));
378+
expect(spawn).toHaveBeenCalledExactlyOnceWith("echo 'foo bar'", expect.objectContaining({}));
379+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo {@}', expect.objectContaining({}));
380380
});
381381

382382
it('argument placeholders are not replaced when additional arguments are not defined', () => {
@@ -388,10 +388,10 @@ it('argument placeholders are not replaced when additional arguments are not def
388388
]);
389389

390390
expect(spawn).toHaveBeenCalledTimes(4);
391-
expect(spawn).toHaveBeenCalledWith('echo {1}', expect.objectContaining({}));
392-
expect(spawn).toHaveBeenCalledWith('echo {@}', expect.objectContaining({}));
393-
expect(spawn).toHaveBeenCalledWith('echo {*}', expect.objectContaining({}));
394-
expect(spawn).toHaveBeenCalledWith('echo {@}', expect.objectContaining({}));
391+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo {1}', expect.objectContaining({}));
392+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo {@}', expect.objectContaining({}));
393+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo {*}', expect.objectContaining({}));
394+
expect(spawn).toHaveBeenCalledExactlyOnceWith('echo {@}', expect.objectContaining({}));
395395
});
396396

397397
it('runs onFinish hook after all commands run', async () => {

src/flow-control/input-handler.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ it('forwards input stream to default target ID', () => {
4949
inputStream.write('something');
5050

5151
expect(commands[0].stdin?.write).toHaveBeenCalledTimes(1);
52-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('something');
52+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('something');
5353
expect(commands[1].stdin?.write).not.toHaveBeenCalled();
5454
});
5555

@@ -61,8 +61,8 @@ it('forwards input stream to target index specified in input', () => {
6161

6262
expect(commands[0].stdin?.write).not.toHaveBeenCalled();
6363
expect(commands[1].stdin?.write).toHaveBeenCalledTimes(2);
64-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('something');
65-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('multi\nline\n');
64+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('something');
65+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('multi\nline\n');
6666
});
6767

6868
it('forwards input stream to target index specified in input when input contains colon', () => {
@@ -74,9 +74,9 @@ it('forwards input stream to target index specified in input when input contains
7474

7575
expect(commands[0].stdin?.write).not.toHaveBeenCalled();
7676
expect(commands[1].stdin?.write).toHaveBeenCalledTimes(3);
77-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('some:thing');
78-
expect(commands[1].stdin?.write).toHaveBeenCalledWith(' :something');
79-
expect(commands[1].stdin?.write).toHaveBeenCalledWith(':something');
77+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('some:thing');
78+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith(' :something');
79+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith(':something');
8080
});
8181

8282
it('does not forward input stream when input contains colon in a different format', () => {
@@ -91,14 +91,14 @@ it('does not forward input stream when input contains colon in a different forma
9191
inputStream.emit('data', Buffer.from('js_obj = {key: "my_val"}'));
9292

9393
expect(commands[1].stdin?.write).toHaveBeenCalledTimes(1);
94-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('Ruby1::Const::Syntax');
94+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('Ruby1::Const::Syntax');
9595
expect(commands[0].stdin?.write).toHaveBeenCalledTimes(6);
96-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('Ruby0::Const::Syntax');
97-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('ruby_symbol_arg :my_symbol');
98-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('ruby_symbol_arg(:my_symbol)');
99-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('{ruby_key: :my_val}');
100-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('{:ruby_key=>:my_val}');
101-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('js_obj = {key: "my_val"}');
96+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('Ruby0::Const::Syntax');
97+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('ruby_symbol_arg :my_symbol');
98+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('ruby_symbol_arg(:my_symbol)');
99+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('{ruby_key: :my_val}');
100+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('{:ruby_key=>:my_val}');
101+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('js_obj = {key: "my_val"}');
102102
});
103103

104104
it('forwards input stream to target name specified in input', () => {
@@ -108,7 +108,7 @@ it('forwards input stream to target name specified in input', () => {
108108

109109
expect(commands[0].stdin?.write).not.toHaveBeenCalled();
110110
expect(commands[1].stdin?.write).toHaveBeenCalledTimes(1);
111-
expect(commands[1].stdin?.write).toHaveBeenCalledWith('something');
111+
expect(commands[1].stdin?.write).toHaveBeenCalledExactlyOnceWith('something');
112112
});
113113

114114
it('logs error if command has no stdin open', () => {
@@ -118,7 +118,7 @@ it('logs error if command has no stdin open', () => {
118118
inputStream.write('something');
119119

120120
expect(commands[1].stdin?.write).not.toHaveBeenCalled();
121-
expect(logger.logGlobalEvent).toHaveBeenCalledWith(
121+
expect(logger.logGlobalEvent).toHaveBeenCalledExactlyOnceWith(
122122
'Unable to find command "0", or it has no stdin open\n',
123123
);
124124
});
@@ -129,7 +129,7 @@ it('fallback to default input stream if command is not found', () => {
129129
inputStream.write('foobar:something');
130130

131131
expect(commands[0].stdin?.write).toHaveBeenCalledTimes(1);
132-
expect(commands[0].stdin?.write).toHaveBeenCalledWith('foobar:something');
132+
expect(commands[0].stdin?.write).toHaveBeenCalledExactlyOnceWith('foobar:something');
133133
expect(commands[1].stdin?.write).not.toHaveBeenCalled();
134134
expect(logger.logGlobalEvent).not.toHaveBeenCalled();
135135
});

0 commit comments

Comments
 (0)