test: use node helpers for events.once and setTimeout promise (#37374)

This commit is contained in:
Jeremy Rose 2023-02-23 15:53:53 -08:00 committed by GitHub
parent 46c8b9c728
commit a3e3efe4c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 932 additions and 927 deletions

View file

@ -6,8 +6,8 @@ import * as url from 'url';
import * as WebSocket from 'ws';
import { ipcMain, protocol, session, WebContents, webContents } from 'electron/main';
import { Socket } from 'net';
import { emittedOnce } from './lib/events-helpers';
import { listen } from './lib/spec-helpers';
import { once } from 'events';
const fixturesPath = path.resolve(__dirname, 'fixtures');
@ -545,7 +545,7 @@ describe('webRequest module', () => {
});
contents.loadFile(path.join(fixturesPath, 'api', 'webrequest.html'), { query: { port: `${port}` } });
await emittedOnce(ipcMain, 'websocket-success');
await once(ipcMain, 'websocket-success');
expect(receivedHeaders['/websocket'].Upgrade[0]).to.equal('websocket');
expect(receivedHeaders['/'].foo1[0]).to.equal('bar1');