test: convert functions to async & eliminate duplicates (#37316)

test: convert functions to async

Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Milan Burda 2023-02-20 12:30:57 +01:00 committed by GitHub
parent 969665eaa2
commit f97d68c4bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 225 additions and 343 deletions

View file

@ -5,8 +5,8 @@ import * as os from 'os';
import * as path from 'path';
import * as ChildProcess from 'child_process';
import { session, net } from 'electron/main';
import { Socket, AddressInfo } from 'net';
import { ifit } from './lib/spec-helpers';
import { Socket } from 'net';
import { ifit, listen } from './lib/spec-helpers';
import { emittedOnce } from './lib/events-helpers';
const appPath = path.join(__dirname, 'fixtures', 'api', 'net-log');
@ -20,12 +20,8 @@ describe('netLog module', () => {
let serverUrl: string;
const connections: Set<Socket> = new Set();
before(done => {
before(async () => {
server = http.createServer();
server.listen(0, '127.0.0.1', () => {
serverUrl = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
done();
});
server.on('connection', (connection) => {
connections.add(connection);
connection.once('close', () => {
@ -35,6 +31,7 @@ describe('netLog module', () => {
server.on('request', (request, response) => {
response.end();
});
serverUrl = (await listen(server)).url;
});
after(done => {