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

This commit is contained in:
Milan Burda 2023-11-17 10:44:03 +01:00 committed by GitHub
parent 471449d9f6
commit 67894f1493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 61 deletions

View file

@ -11,6 +11,7 @@ import * as dbus from 'dbus-native';
import { ifdescribe, startRemoteControlApp } from './lib/spec-helpers';
import { promisify } from 'node:util';
import { setTimeout } from 'node:timers/promises';
import { once } from 'node:events';
describe('powerMonitor', () => {
let logindMock: any, dbusMockPowerMonitor: any, getCalls: any, emitSignal: any, reset: any;
@ -77,17 +78,19 @@ describe('powerMonitor', () => {
});
describe('when PrepareForSleep(true) signal is sent by logind', () => {
it('should emit "suspend" event', (done) => {
dbusMockPowerMonitor.once('suspend', () => done());
it('should emit "suspend" event', async () => {
const suspend = once(dbusMockPowerMonitor, 'suspend');
emitSignal('org.freedesktop.login1.Manager', 'PrepareForSleep',
'b', [['b', true]]);
await suspend;
});
describe('when PrepareForSleep(false) signal is sent by logind', () => {
it('should emit "resume" event', done => {
dbusMockPowerMonitor.once('resume', () => done());
it('should emit "resume" event', async () => {
const resume = once(dbusMockPowerMonitor, 'resume');
emitSignal('org.freedesktop.login1.Manager', 'PrepareForSleep',
'b', [['b', false]]);
await resume;
});
it('should have called Inhibit again', async () => {