test: fix typings for DoneFn
(#25163)
This also fixes CI tests, which were accidentally broken in #24663. PR Close #25163
This commit is contained in:

committed by
Igor Minar

parent
e8d4211d5c
commit
342678486d
@ -35,18 +35,14 @@
|
||||
* @param blockFn function to wrap. The function can return promise or be `async`.
|
||||
* @experimental
|
||||
*/
|
||||
export function withBody<T>(html: string, blockFn: T): T {
|
||||
return function(done: {(): void, fail(): void}) {
|
||||
export function withBody<T extends Function>(html: string, blockFn: T): T {
|
||||
return function(done: DoneFn) {
|
||||
ensureDocument();
|
||||
let returnValue: any = undefined;
|
||||
if (typeof blockFn === 'function') {
|
||||
document.body.innerHTML = html;
|
||||
// TODO(i): I'm not sure why a cast is required here but otherwise I get
|
||||
// TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'never' has
|
||||
// no compatible call signatures.
|
||||
let blockReturn = (blockFn as any)();
|
||||
const blockReturn = blockFn();
|
||||
if (blockReturn instanceof Promise) {
|
||||
blockReturn = blockReturn.then(done, done.fail);
|
||||
blockReturn.then(done, done.fail);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
@ -124,4 +120,4 @@ export function cleanupDocument(): void {
|
||||
}
|
||||
|
||||
if (typeof beforeEach == 'function') beforeEach(ensureDocument);
|
||||
if (typeof afterEach == 'function') beforeEach(cleanupDocument);
|
||||
if (typeof afterEach == 'function') beforeEach(cleanupDocument);
|
||||
|
Reference in New Issue
Block a user