test: convert a few more specs to async/await (#40313)
This commit is contained in:
parent
471449d9f6
commit
67894f1493
8 changed files with 48 additions and 61 deletions
|
@ -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 () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue