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

@ -4,8 +4,8 @@ import * as path from 'path';
import { session, webContents, WebContents } from 'electron/main';
import { expect } from 'chai';
import { v4 } from 'uuid';
import { AddressInfo } from 'net';
import { emittedOnce, emittedNTimes } from './lib/events-helpers';
import { listen } from './lib/spec-helpers';
const partition = 'service-workers-spec';
@ -32,12 +32,8 @@ describe('session.serviceWorkers', () => {
}
res.end(fs.readFileSync(path.resolve(__dirname, 'fixtures', 'api', 'service-workers', file)));
});
await new Promise<void>(resolve => {
server.listen(0, '127.0.0.1', () => {
baseUrl = `http://localhost:${(server.address() as AddressInfo).port}/${uuid}`;
resolve();
});
});
const { port } = await listen(server);
baseUrl = `http://localhost:${port}/${uuid}`;
w = (webContents as typeof ElectronInternal.WebContents).create({ session: ses });
});