-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
36 lines (29 loc) · 969 Bytes
/
test.js
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
import process from 'node:process';
import test from 'ava';
import noopProcess from 'noop-process';
import {processExists, processExistsMultiple, filterExistingProcesses} from './index.js';
test('pid', async t => {
t.true(await processExists(process.pid));
t.false(await processExists(345_234_531));
});
test('title', async t => {
const title = 'pe-test';
await noopProcess({title});
t.true(await processExists(title));
t.false(await processExists('pe-unicorn'));
});
test('multiple', async t => {
const title = 'pe-test';
await noopProcess({title});
t.deepEqual(await processExistsMultiple([process.pid, title, 345_234_531, 'pe-unicorn']), new Map([
[process.pid, true],
[title, true],
[345_234_531, false],
['pe-unicorn', false],
]));
});
test('filter', async t => {
const title = 'pe-test';
await noopProcess({title});
t.deepEqual(await filterExistingProcesses([process.pid, title, 345_234_531, 'pe-unicorn']), [process.pid, title]);
});