forked from sindresorhus/fkill
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
42 lines (35 loc) · 907 Bytes
/
test.js
File metadata and controls
42 lines (35 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* eslint-disable ava/no-identical-title */
import childProcess from 'child_process';
import test from 'ava';
import noopProcess from 'noop-process';
import processExists from 'process-exists';
import m from './';
test('pid', async t => {
const pid = await noopProcess();
await m(pid, {force: true});
t.false(await processExists(pid));
});
if (process.platform === 'win32') {
test('title', async t => {
const title = 'notepad.exe';
const pid = childProcess.spawn(title).pid;
await m(title);
t.false(await processExists(pid));
});
} else {
test('title', async t => {
const title = 'fkill-test';
const pid = await noopProcess({title: title});
await m(title);
t.false(await processExists(pid));
});
test('fail', async t => {
try {
await m(['123456', '654321']);
t.fail();
} catch (err) {
t.regex(err.message, /123456/);
t.regex(err.message, /654321/);
}
});
}