bunch of changes
This commit is contained in:
+15
-1
@@ -2,7 +2,7 @@ import http from 'http';
|
||||
import net from 'net';
|
||||
import assert from 'assert';
|
||||
|
||||
import TunnelAgent from './TunnelAgent';
|
||||
import TunnelAgent from './TunnelAgent.js';
|
||||
|
||||
describe('TunnelAgent', () => {
|
||||
it('should create an empty agent', async () => {
|
||||
@@ -180,4 +180,18 @@ describe('TunnelAgent', () => {
|
||||
connectedSockets: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('should disconnect clients by timeout', async () => {
|
||||
const agent = new TunnelAgent({socketTimeout: 600});
|
||||
const info = await agent.listen();
|
||||
|
||||
const offlinePromise = new Promise(resolve => agent.once('offline', resolve));
|
||||
|
||||
const sock = net.createConnection({ port: info.port });
|
||||
await new Promise(resolve => sock.once('connect', resolve));
|
||||
|
||||
await offlinePromise;
|
||||
agent.destroy();
|
||||
sock.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user