Skip to content

Commit

Permalink
refactor: waitForTrue -> waitUntil
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmaddock committed Apr 22, 2021
1 parent 9c5ae84 commit 271a5cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spec-main/api-web-frame-main-spec.ts
Expand Up @@ -6,7 +6,7 @@ import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain } from 'electron/mai
import { closeAllWindows } from './window-helpers';
import { emittedOnce, emittedNTimes } from './events-helpers';
import { AddressInfo } from 'net';
import { waitForTrue } from './spec-helpers';
import { waitUntil } from './spec-helpers';

describe('webFrameMain module', () => {
const fixtures = path.resolve(__dirname, '..', 'spec-main', 'fixtures');
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('webFrameMain module', () => {
expect(webFrame.visibilityState).to.equal('visible');
w.hide();
await expect(
waitForTrue(() => webFrame.visibilityState === 'hidden')
waitUntil(() => webFrame.visibilityState === 'hidden')
).to.eventually.be.fulfilled();
});
});
Expand Down
6 changes: 3 additions & 3 deletions spec-main/spec-helpers.ts
Expand Up @@ -87,7 +87,7 @@ export async function startRemoteControlApp () {
return new RemoteControlApp(appProcess, port);
}

export function waitForTrue (
export function waitUntil (
callback: () => boolean,
opts: { rate?: number, timeout?: number } = {}
) {
Expand Down Expand Up @@ -115,8 +115,8 @@ export function waitForTrue (
if (result === true) {
cleanup();
resolve();
return true;
}
return result;
};

if (check()) {
Expand All @@ -128,7 +128,7 @@ export function waitForTrue (
timeoutId = setTimeout(() => {
timeoutId = undefined;
cleanup();
reject(new Error(`waitForTrue timed out after ${timeout}ms`));
reject(new Error(`waitUntil timed out after ${timeout}ms`));
}, timeout);
});
}

0 comments on commit 271a5cc

Please sign in to comment.