[node] Some fixes for net and https (#20662)

Sync Lookup function type in net, tls and dgram.
This commit is contained in:
Flarna
2017-10-23 13:17:14 -07:00
committed by Sheetal Nandi
parent e05709a29d
commit eba2b89b3c
2 changed files with 69 additions and 84 deletions
+25 -15
View File
@@ -1198,6 +1198,7 @@ namespace http_tests {
const timeout: number = server.timeout;
const listening: boolean = server.listening;
const keepAliveTimeout: number = server.keepAliveTimeout;
server.setTimeout().setTimeout(1000).setTimeout(() => {}).setTimeout(100, () => {});
}
// http IncomingMessage
@@ -1347,6 +1348,15 @@ namespace https_tests {
});
https.request('http://www.example.com/xyz');
{
const server = new https.Server();
const timeout: number = server.timeout;
const listening: boolean = server.listening;
const keepAliveTimeout: number = server.keepAliveTimeout;
server.setTimeout().setTimeout(1000).setTimeout(() => {}).setTimeout(100, () => {});
}
}
////////////////////////////////////////////////////
@@ -1857,23 +1867,23 @@ namespace child_process_tests {
childProcess.spawnSync("echo test");
}
{
childProcess.execFile("npm", () => {});
childProcess.execFile("npm", ["-v"], () => {});
childProcess.execFile("npm", ["-v"], { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); });
childProcess.execFile("npm", ["-v"], { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); });
childProcess.execFile("npm", { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); });
childProcess.execFile("npm", { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); });
}
{
childProcess.execFile("npm", () => {});
childProcess.execFile("npm", ["-v"], () => {});
childProcess.execFile("npm", ["-v"], { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); });
childProcess.execFile("npm", ["-v"], { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); });
childProcess.execFile("npm", { encoding: 'utf-8' }, (stdout, stderr) => { assert(stdout instanceof String); });
childProcess.execFile("npm", { encoding: 'buffer' }, (stdout, stderr) => { assert(stdout instanceof Buffer); });
}
async function testPromisify() {
const execFile = util.promisify(childProcess.execFile);
let r: { stdout: string | Buffer, stderr: string | Buffer } = await execFile("npm");
r = await execFile("npm", ["-v"]);
r = await execFile("npm", ["-v"], { encoding: 'utf-8' });
r = await execFile("npm", ["-v"], { encoding: 'buffer' });
r = await execFile("npm", { encoding: 'utf-8' });
r = await execFile("npm", { encoding: 'buffer' });
let r: { stdout: string | Buffer, stderr: string | Buffer } = await execFile("npm");
r = await execFile("npm", ["-v"]);
r = await execFile("npm", ["-v"], { encoding: 'utf-8' });
r = await execFile("npm", ["-v"], { encoding: 'buffer' });
r = await execFile("npm", { encoding: 'utf-8' });
r = await execFile("npm", { encoding: 'buffer' });
}
{
@@ -2529,7 +2539,7 @@ namespace net_tests {
host: "localhost",
localAddress: "10.0.0.1",
localPort: 1234,
lookup: (_hostname: string, _options: dns.LookupOneOptions, _callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void => {
lookup: (_hostname: string, _options: dns.LookupOneOptions, _callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void => {
// nothing
},
port: 80