mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #47888 [qunit] Explicitly support Promise callbacks by @wagenet
The lack of explicit support is generally not problematic except when used in conjunction with @typescript-eslint/no-misused-promises which complains when a Promise is provided to a function that doesn't allow for it.
This commit is contained in:
parent
e4455c0b0a
commit
deea912e89
12
types/qunit/index.d.ts
vendored
12
types/qunit/index.d.ts
vendored
@ -429,7 +429,7 @@ declare global {
|
||||
*
|
||||
* @callback callback Callback to execute.
|
||||
*/
|
||||
begin(callback: (details: QUnit.BeginDetails) => void): void;
|
||||
begin(callback: (details: QUnit.BeginDetails) => void | Promise<void>): void;
|
||||
|
||||
/**
|
||||
* Configuration for QUnit
|
||||
@ -444,7 +444,7 @@ declare global {
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
done(callback: (details: QUnit.DoneDetails) => void): void;
|
||||
done(callback: (details: QUnit.DoneDetails) => void | Promise<void>): void;
|
||||
|
||||
/**
|
||||
* Advanced and extensible data dumping for JavaScript.
|
||||
@ -535,14 +535,14 @@ declare global {
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
moduleDone(callback: (details: QUnit.ModuleDoneDetails) => void): void;
|
||||
moduleDone(callback: (details: QUnit.ModuleDoneDetails) => void | Promise<void>): void;
|
||||
|
||||
/**
|
||||
* Register a callback to fire whenever a module begins.
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
moduleStart(callback: (details: QUnit.ModuleStartDetails) => void): void;
|
||||
moduleStart(callback: (details: QUnit.ModuleStartDetails) => void | Promise<void>): void;
|
||||
|
||||
/**
|
||||
* Adds a test to exclusively run, preventing all other tests from running.
|
||||
@ -651,14 +651,14 @@ declare global {
|
||||
passed: number;
|
||||
total: number;
|
||||
runtime: number;
|
||||
}) => void): void;
|
||||
}) => void | Promise<void>): void;
|
||||
|
||||
/**
|
||||
* Register a callback to fire whenever a test begins.
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
testStart(callback: (details: QUnit.TestStartDetails) => void): void;
|
||||
testStart(callback: (details: QUnit.TestStartDetails) => void | Promise<void>): void;
|
||||
|
||||
/**
|
||||
* Adds a test which expects at least one failing assertion during its run.
|
||||
|
||||
@ -270,6 +270,37 @@ QUnit.testStart(function( details: QUnit.TestStartDetails ) {
|
||||
console.log( "Now running: ", details.name, ' from module ', details.module );
|
||||
});
|
||||
|
||||
async function timeout() {
|
||||
return new Promise(resolve => setTimeout(resolve, 1));
|
||||
}
|
||||
|
||||
// These async tests are intended to ensure the appropriate behavior for @typescript-eslint/no-misused-promises.
|
||||
// However, we don't actually use typescript-eslint in this project and tslint has no equivalent,
|
||||
// so we can't properly test it.
|
||||
QUnit.begin(async function() {
|
||||
await timeout();
|
||||
});
|
||||
|
||||
QUnit.done(async function() {
|
||||
await timeout();
|
||||
});
|
||||
|
||||
QUnit.moduleDone(async function() {
|
||||
await timeout();
|
||||
});
|
||||
|
||||
QUnit.moduleStart(async function() {
|
||||
await timeout();
|
||||
});
|
||||
|
||||
QUnit.testDone(async function() {
|
||||
await timeout();
|
||||
});
|
||||
|
||||
QUnit.testStart(async function() {
|
||||
await timeout();
|
||||
});
|
||||
|
||||
let Robot: any = () => {};
|
||||
|
||||
QUnit.module( "robot", {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user