test: convert a few more specs to async/await (#39712)

This commit is contained in:
Milan Burda 2023-09-04 12:33:29 +02:00 committed by GitHub
parent 54d8402a6c
commit f27b034045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 70 additions and 89 deletions

View file

@ -3,6 +3,7 @@ import { Menu, Tray } from 'electron/main';
import { nativeImage } from 'electron/common';
import { ifdescribe, ifit } from './lib/spec-helpers';
import * as path from 'node:path';
import { setTimeout } from 'node:timers/promises';
describe('tray module', () => {
let tray: Tray;
@ -74,12 +75,11 @@ describe('tray module', () => {
});
describe('tray.popUpContextMenu()', () => {
ifit(process.platform === 'win32')('can be called when menu is showing', function (done) {
ifit(process.platform === 'win32')('can be called when menu is showing', async function () {
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]));
setTimeout(() => {
tray.popUpContextMenu();
done();
});
const timeout = setTimeout();
tray.popUpContextMenu();
await timeout;
tray.popUpContextMenu();
});
@ -115,14 +115,13 @@ describe('tray module', () => {
});
describe('tray.closeContextMenu()', () => {
ifit(process.platform === 'win32')('does not crash when called more than once', function (done) {
ifit(process.platform === 'win32')('does not crash when called more than once', async function () {
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]));
setTimeout(() => {
tray.closeContextMenu();
tray.closeContextMenu();
done();
});
const timeout = setTimeout();
tray.popUpContextMenu();
await timeout;
tray.closeContextMenu();
tray.closeContextMenu();
});
});