blob: ec36a3a21cb3cfaa7d17b730ebb69e7d51ea2cd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
// SPDX-FileCopyrightText: 2022 Evan Welsh <contact@evanwelsh.com>
import GLib from 'gi://GLib';
import {acquireMainloop} from 'resource:///org/gjs/jsunit/minijasmine.js';
describe('Async mainloop', function () {
let loop, quit;
beforeEach(function () {
loop = new GLib.MainLoop(null, false);
quit = jasmine.createSpy('quit').and.callFake(() => {
loop.quit();
return GLib.SOURCE_REMOVE;
});
});
it('resolves when main loop exits', async function () {
const release = acquireMainloop();
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 50, quit);
await loop.runAsync();
expect(quit).toHaveBeenCalled();
release();
});
});
|