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:
parent
e8d4211d5c
commit
342678486d
|
@ -29,7 +29,7 @@ describe('largeform benchmark perf', () => {
|
|||
|
||||
[CreateAndDestroyWorker].forEach((worker) => {
|
||||
describe(worker.id, () => {
|
||||
it('should run for ng2', (done: any) => {
|
||||
it('should run for ng2', done => {
|
||||
runLargeFormBenchmark({
|
||||
id: `largeform.ng2.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largeform/ng2/index.html',
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('largetable benchmark perf', () => {
|
|||
|
||||
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
|
||||
describe(worker.id, () => {
|
||||
it('should run for ng2', (done: any) => {
|
||||
it('should run for ng2', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.ng2.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largetable/ng2/index.html',
|
||||
|
@ -48,7 +48,7 @@ describe('largetable benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for ng2 with ngSwitch', (done: any) => {
|
||||
it('should run for ng2 with ngSwitch', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.ng2_switch.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largetable/ng2_switch/index.html',
|
||||
|
@ -56,7 +56,7 @@ describe('largetable benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for render3', (done: any) => {
|
||||
it('should run for render3', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.render3.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largetable/render3/index.html',
|
||||
|
@ -65,7 +65,7 @@ describe('largetable benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for iv', (done: any) => {
|
||||
it('should run for iv', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.iv.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largetable/iv/index.html',
|
||||
|
@ -74,7 +74,7 @@ describe('largetable benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for the baseline', (done: any) => {
|
||||
it('should run for the baseline', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.baseline.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largetable/baseline/index.html',
|
||||
|
@ -83,7 +83,7 @@ describe('largetable benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for incremental-dom', (done: any) => {
|
||||
it('should run for incremental-dom', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.incremental_dom.${worker.id}`,
|
||||
url: 'all/benchmarks/src/largetable/incremental_dom/index.html',
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('tree benchmark perf', () => {
|
|||
Benchmarks.forEach(benchmark => {
|
||||
describe(benchmark.id, () => {
|
||||
// This is actually a destroyOnly benchmark
|
||||
it('should work for createOnly', (done: any) => {
|
||||
it('should work for createOnly', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'createOnly',
|
||||
benchmark,
|
||||
|
@ -33,7 +33,7 @@ describe('tree benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should work for createOnlyForReal', (done: any) => {
|
||||
it('should work for createOnlyForReal', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'createOnlyForReal',
|
||||
benchmark,
|
||||
|
@ -42,7 +42,7 @@ describe('tree benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should work for createDestroy', (done: any) => {
|
||||
it('should work for createDestroy', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'createDestroy',
|
||||
benchmark,
|
||||
|
@ -53,13 +53,13 @@ describe('tree benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should work for update', (done: any) => {
|
||||
it('should work for update', done => {
|
||||
runTreeBenchmark({id: 'update', benchmark, work: () => $(CreateBtn).click()})
|
||||
.then(done, done.fail);
|
||||
});
|
||||
|
||||
if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) {
|
||||
it('should work for detectChanges', (done: any) => {
|
||||
it('should work for detectChanges', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'detectChanges',
|
||||
benchmark,
|
||||
|
|
|
@ -41,7 +41,7 @@ describe('largetable benchmark perf', () => {
|
|||
|
||||
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
|
||||
describe(worker.id, () => {
|
||||
it('should run for render3', (done) => {
|
||||
it('should run for render3', done => {
|
||||
runTableBenchmark({
|
||||
id: `largeTable.render3.${worker.id}`,
|
||||
url: 'index.html',
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {withBody} from '@angular/core/testing';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -104,9 +104,9 @@ class BadTemplateUrl {
|
|||
reject = rej;
|
||||
});
|
||||
originalJasmineIt = jasmine.getEnv().it;
|
||||
jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */): any => {
|
||||
const done = () => { resolve(null); };
|
||||
(<any>done).fail = (err: any /** TODO #9100 */) => { reject(err); };
|
||||
jasmine.getEnv().it = (description: string, fn: (done: DoneFn) => void): any => {
|
||||
const done = (() => resolve(null)) as DoneFn;
|
||||
done.fail = reject;
|
||||
fn(done);
|
||||
return null;
|
||||
};
|
||||
|
@ -115,7 +115,7 @@ class BadTemplateUrl {
|
|||
|
||||
const restoreJasmineIt = () => { jasmine.getEnv().it = originalJasmineIt; };
|
||||
|
||||
it('should fail when an ResourceLoader fails', (done: any /** TODO #9100 */) => {
|
||||
it('should fail when an ResourceLoader fails', done => {
|
||||
const itPromise = patchJasmineIt();
|
||||
|
||||
it('should fail with an error from a promise', async(() => {
|
||||
|
|
|
@ -148,7 +148,7 @@ export declare type TestModuleMetadata = {
|
|||
export declare function tick(millis?: number): void;
|
||||
|
||||
/** @experimental */
|
||||
export declare function withBody<T>(html: string, blockFn: T): T;
|
||||
export declare function withBody<T extends Function>(html: string, blockFn: T): T;
|
||||
|
||||
/** @experimental */
|
||||
export declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/// <reference types="jasminewd2" />
|
||||
|
||||
/**
|
||||
* Extended typings for `jasminewd2`.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue