forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocks.ts
More file actions
26 lines (22 loc) · 811 Bytes
/
mocks.ts
File metadata and controls
26 lines (22 loc) · 811 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
import { EventEmitter } from 'events';
import { injectable } from 'inversify';
import { IUnitTestSocketServer } from '../../client/testing/common/types';
@injectable()
export class MockUnitTestSocketServer extends EventEmitter implements IUnitTestSocketServer {
private results: {}[] = [];
public reset() {
this.removeAllListeners();
}
public addResults(results: {}[]) {
this.results.push(...results);
}
public async start(options: { port: number; host: string } = { port: 0, host: 'localhost' }): Promise<number> {
this.results.forEach((result) => {
this.emit('result', result);
});
this.results = [];
return typeof options.port === 'number' ? options.port! : 0;
}
public stop(): void {}
public dispose() {}
}