-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdeepnoteTestHelpers.node.ts
More file actions
70 lines (69 loc) · 1.77 KB
/
deepnoteTestHelpers.node.ts
File metadata and controls
70 lines (69 loc) · 1.77 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type { ChildProcess } from 'node:child_process';
/**
* Creates a mock ChildProcess for use in Deepnote server info tests.
* Satisfies the ChildProcess interface with minimal stub values.
*/
export function createMockChildProcess(overrides?: Partial<ChildProcess>): ChildProcess {
const mockProcess: ChildProcess = {
pid: undefined,
stdio: [null, null, null, null, null],
stdin: null,
stdout: null,
stderr: null,
exitCode: null,
killed: false,
connected: false,
signalCode: null,
spawnargs: [],
spawnfile: '',
kill: () => true,
send: () => true,
disconnect: () => true,
unref: () => true,
ref: () => true,
addListener: function () {
return this;
},
emit: () => true,
on: function () {
return this;
},
once: function () {
return this;
},
removeListener: function () {
return this;
},
removeAllListeners: function () {
return this;
},
prependListener: function () {
return this;
},
prependOnceListener: function () {
return this;
},
[Symbol.dispose]: () => {
return undefined;
},
off: function () {
return this;
},
setMaxListeners: function () {
return this;
},
getMaxListeners: () => 10,
listeners: function () {
return [];
},
rawListeners: function () {
return [];
},
eventNames: function () {
return [];
},
listenerCount: () => 0,
...overrides
};
return mockProcess;
}