Debian Codegraph @

pkg/base1/test-promise.ts

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 import cockpit from "cockpit";
3 import QUnit from "qunit-tests";
4
5 QUnit.test("should be able to dispatch es2015 promises", function (assert) {
6 // https://github.com/cockpit-project/cockpit/issues/10956
7
8 assert.expect(1);
9
10 const done = assert.async();
11 const dfd = cockpit.defer();
12
13 dfd.promise.then(() => Promise.resolve(42))
14 .then(result => {
15 assert.equal(result, 42);
16 done();
17 });
18
19 dfd.resolve();
20 });
21
22 QUnit.start();