-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwmic.js
More file actions
48 lines (38 loc) 路 1.03 KB
/
Copy pathwmic.js
File metadata and controls
48 lines (38 loc) 路 1.03 KB
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
43
44
45
46
47
48
import test from 'ava';
import mockery from 'mockery';
import pify from 'pify';
import mocks from './helpers/mocks';
test.before(() => {
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false,
useCleanCache: true,
});
});
test.beforeEach(() => {
mockery.resetCache();
});
test.after(() => {
mockery.disable();
});
test('should parse wmic output on Windows', async t => {
const stdout =
`ParentProcessId ProcessId\r\r\n` +
`0 777 \r\r\n` +
`777 778 \r\r\n` +
`0 779 \r\r\n\r\r\n`;
mockery.registerMock('child_process', {
spawn: () => mocks.spawn(stdout, '', null, 0, null),
});
mockery.registerMock('os', {
EOL: '\r\n',
platform: () => 'linux',
type: () => 'type',
release: () => 'release',
});
const wmic = require('../lib/wmic');
const result = await pify(wmic)();
t.deepEqual(result, [[0, 777], [777, 778], [0, 779]]);
mockery.deregisterMock('child_process');
mockery.deregisterMock('os');
});