mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 09:10:09 +00:00
[@types/qunit] extract callback argument types to interfaces (#27616)
* fix: extract QUnit callback argument types to interfaces * move event callback interfaces into QUnit namespace * Combine function argument type assertions into function declarations
This commit is contained in:
committed by
Sheetal Nandi
parent
bb6b63a59b
commit
b80b4b5e94
59
types/qunit/index.d.ts
vendored
59
types/qunit/index.d.ts
vendored
@@ -340,6 +340,38 @@ interface NestedHooks {
|
||||
|
||||
}
|
||||
|
||||
declare namespace QUnit {
|
||||
interface BeginDetails { totalTests: number }
|
||||
interface DoneDetails { failed: number, passed: number, total: number, runtime: number }
|
||||
interface LogDetails {
|
||||
result: boolean,
|
||||
actual: any;
|
||||
expected: any;
|
||||
message: string;
|
||||
source: string;
|
||||
module: string;
|
||||
name: string;
|
||||
runtime: number;
|
||||
}
|
||||
interface ModuleDoneDetails {
|
||||
name: string;
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
runtime: number;
|
||||
}
|
||||
interface ModuleStartDetails { name: string }
|
||||
interface TestDoneDetails {
|
||||
name: string;
|
||||
module: string;
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
runtime: number;
|
||||
}
|
||||
interface TestStartDetails { name: string; module: string; }
|
||||
}
|
||||
|
||||
interface QUnit {
|
||||
|
||||
/**
|
||||
@@ -360,7 +392,7 @@ interface QUnit {
|
||||
*
|
||||
* @callback callback Callback to execute.
|
||||
*/
|
||||
begin(callback: (details: { totalTests: number }) => void): void;
|
||||
begin(callback: (details: QUnit.BeginDetails) => void): void;
|
||||
|
||||
/**
|
||||
* Configuration for QUnit
|
||||
@@ -375,7 +407,7 @@ interface QUnit {
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
done(callback: (details: { failed: number, passed: number, total: number, runtime: number }) => void): void;
|
||||
done(callback: (details: QUnit.DoneDetails) => void): void;
|
||||
|
||||
/**
|
||||
* Advanced and extensible data dumping for JavaScript.
|
||||
@@ -419,16 +451,7 @@ interface QUnit {
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
log(callback: (details: {
|
||||
result: boolean,
|
||||
actual: any;
|
||||
expected: any;
|
||||
message: string;
|
||||
source: string;
|
||||
module: string;
|
||||
name: string;
|
||||
runtime: number;
|
||||
}) => void): void;
|
||||
log(callback: (details: QUnit.LogDetails) => void): void;
|
||||
|
||||
/**
|
||||
* Group related tests under a single label.
|
||||
@@ -476,20 +499,14 @@ interface QUnit {
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
moduleDone(callback: (details: {
|
||||
name: string;
|
||||
failed: number;
|
||||
passed: number;
|
||||
total: number;
|
||||
runtime: number;
|
||||
}) => void): void;
|
||||
moduleDone(callback: (details: QUnit.ModuleDoneDetails) => void): void;
|
||||
|
||||
/**
|
||||
* Register a callback to fire whenever a module begins.
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
moduleStart(callback: (details: { name: string }) => void): void;
|
||||
moduleStart(callback: (details: QUnit.ModuleStartDetails) => void): void;
|
||||
|
||||
/**
|
||||
* Adds a test to exclusively run, preventing all other tests from running.
|
||||
@@ -605,7 +622,7 @@ interface QUnit {
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
*/
|
||||
testStart(callback: (details: { name: string; module: string;}) => void): void;
|
||||
testStart(callback: (details: QUnit.TestStartDetails) => void): void;
|
||||
|
||||
/**
|
||||
* Adds a test which expects at least one failing assertion during its run.
|
||||
|
||||
@@ -214,13 +214,33 @@ QUnit.log(function( details ) {
|
||||
console.log( output );
|
||||
});
|
||||
|
||||
QUnit.moduleDone(function( details ) {
|
||||
console.log( "Finished running: ", details.name, "Failed/total: ", details.failed, details.total );
|
||||
QUnit.log(function( details: QUnit.LogDetails ) {
|
||||
let x: { actual: number; expected: number; message: string; module: string; name: string; result: boolean; runtime: number; source: string } = details;
|
||||
x = details;
|
||||
});
|
||||
|
||||
QUnit.moduleStart(function( details ) {
|
||||
QUnit.begin(function( details: QUnit.BeginDetails ) {
|
||||
console.log( "Total tests running: ", details.totalTests);
|
||||
});
|
||||
|
||||
QUnit.done(function( details: QUnit.DoneDetails ) {
|
||||
console.log( "Finished. Failed/total: ", details.failed, details.total, details.passed, details.runtime );
|
||||
});
|
||||
|
||||
QUnit.moduleDone(function( details: QUnit.ModuleDoneDetails ) {
|
||||
console.log( "Finished running: ", details.name, "Failed/total: ", details.failed, details.total, details.passed, details.runtime );
|
||||
});
|
||||
|
||||
QUnit.moduleStart(function( details: QUnit.ModuleStartDetails ) {
|
||||
console.log( "Now running: ", details.name );
|
||||
});
|
||||
QUnit.testDone(function( details: QUnit.TestDoneDetails ) {
|
||||
console.log( "Finished running: ", details.name, "Failed/total: ", details.failed, details.total, details.passed, details.runtime);
|
||||
});
|
||||
|
||||
QUnit.testStart(function( details: QUnit.TestStartDetails ) {
|
||||
console.log( "Now running: ", details.name, ' from module ', details.module );
|
||||
});
|
||||
|
||||
let Robot: any = () => {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user