mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #32211 from ajafff/jasmine-async-cb
jasmine: add type for async ImplementationCallback
This commit is contained in:
Vendored
+13
-11
@@ -15,6 +15,8 @@
|
||||
// TypeScript Version: 2.8
|
||||
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
||||
|
||||
type ImplementationCallback = (() => Promise<any>) | ((done: DoneFn) => void);
|
||||
|
||||
/**
|
||||
* Create a group of specs (often called a suite).
|
||||
* @param description Textual description of the group
|
||||
@@ -43,7 +45,7 @@ declare function xdescribe(description: string, specDefinitions: () => void): vo
|
||||
* @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
||||
* @param timeout Custom timeout for an async spec.
|
||||
*/
|
||||
declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function it(expectation: string, assertion?: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* A focused `it`. If suites or specs are focused, only those that are focused will be executed.
|
||||
@@ -51,7 +53,7 @@ declare function it(expectation: string, assertion?: (done: DoneFn) => void, tim
|
||||
* @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
||||
* @param timeout Custom timeout for an async spec.
|
||||
*/
|
||||
declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* A temporarily disabled `it`. The spec will report as pending and will not be executed.
|
||||
@@ -59,7 +61,7 @@ declare function fit(expectation: string, assertion?: (done: DoneFn) => void, ti
|
||||
* @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
||||
* @param timeout Custom timeout for an async spec.
|
||||
*/
|
||||
declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Mark a spec as pending, expectation results will be ignored.
|
||||
@@ -73,14 +75,14 @@ declare function pending(reason?: string): void;
|
||||
* @param action Function that contains the code to setup your specs.
|
||||
* @param timeout Custom timeout for an async beforeEach.
|
||||
*/
|
||||
declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function beforeEach(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Run some shared teardown after each of the specs in the describe in which it is called.
|
||||
* @param action Function that contains the code to teardown your specs.
|
||||
* @param timeout Custom timeout for an async afterEach.
|
||||
*/
|
||||
declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterEach(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Run some shared setup once before all of the specs in the describe are run.
|
||||
@@ -88,7 +90,7 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo
|
||||
* @param action Function that contains the code to setup your specs.
|
||||
* @param timeout Custom timeout for an async beforeAll.
|
||||
*/
|
||||
declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function beforeAll(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Run some shared teardown once before all of the specs in the describe are run.
|
||||
@@ -96,7 +98,7 @@ declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): vo
|
||||
* @param action Function that contains the code to teardown your specs.
|
||||
* @param timeout Custom timeout for an async afterAll
|
||||
*/
|
||||
declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterAll(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Create an expectation for a spec.
|
||||
@@ -302,11 +304,11 @@ declare namespace jasmine {
|
||||
execute(): void;
|
||||
describe(description: string, specDefinitions: () => void): Suite;
|
||||
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
|
||||
beforeEach(beforeEachFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
beforeAll(beforeAllFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
beforeEach(beforeEachFunction: ImplementationCallback, timeout?: number): void;
|
||||
beforeAll(beforeAllFunction: ImplementationCallback, timeout?: number): void;
|
||||
currentRunner(): Runner;
|
||||
afterEach(afterEachFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
afterAll(afterAllFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
afterEach(afterEachFunction: ImplementationCallback, timeout?: number): void;
|
||||
afterAll(afterAllFunction: ImplementationCallback, timeout?: number): void;
|
||||
xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
||||
it(description: string, func: () => void): Spec;
|
||||
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
|
||||
|
||||
@@ -725,12 +725,12 @@ describe("A spy, when created manually", () => {
|
||||
describe("Multiple spies, when created manually", () => {
|
||||
class Tape {
|
||||
private rewindTo: number;
|
||||
play(): void { };
|
||||
pause(): void { };
|
||||
play(): void { }
|
||||
pause(): void { }
|
||||
rewind(pos: number): void {
|
||||
this.rewindTo = pos;
|
||||
};
|
||||
stop(): void { };
|
||||
}
|
||||
stop(): void { }
|
||||
readonly isPlaying: boolean; // spy obj makes this writable
|
||||
}
|
||||
|
||||
|
||||
Vendored
+13
-11
@@ -13,6 +13,8 @@
|
||||
// TypeScript Version: 2.8
|
||||
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
||||
|
||||
type ImplementationCallback = (() => Promise<any>) | ((done: DoneFn) => void);
|
||||
|
||||
/**
|
||||
* Create a group of specs (often called a suite).
|
||||
* @param description Textual description of the group
|
||||
@@ -29,7 +31,7 @@ declare function xdescribe(description: string, specDefinitions: () => void): vo
|
||||
* @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
||||
* @param timeout Custom timeout for an async spec.
|
||||
*/
|
||||
declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function it(expectation: string, assertion?: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* A focused it
|
||||
@@ -38,8 +40,8 @@ declare function it(expectation: string, assertion?: (done: DoneFn) => void, tim
|
||||
* @param assertion
|
||||
* @param timeout
|
||||
*/
|
||||
declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: ImplementationCallback, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Mark a spec as pending, expectation results will be ignored.
|
||||
@@ -54,14 +56,14 @@ declare function pending(reason?: string): void;
|
||||
* @param action Function that contains the code to setup your specs.
|
||||
* @param timeout Custom timeout for an async beforeEach.
|
||||
*/
|
||||
declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function beforeEach(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Run some shared teardown after each of the specs in the describe in which it is called.
|
||||
* @param action Function that contains the code to teardown your specs.
|
||||
* @param timeout Custom timeout for an async afterEach.
|
||||
*/
|
||||
declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterEach(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Run some shared setup once before all of the specs in the describe are run.
|
||||
@@ -69,7 +71,7 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo
|
||||
* @param action Function that contains the code to setup your specs.
|
||||
* @param timeout Custom timeout for an async beforeAll.
|
||||
*/
|
||||
declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function beforeAll(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Run some shared teardown once before all of the specs in the describe are run.
|
||||
@@ -77,7 +79,7 @@ declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): vo
|
||||
* @param action Function that contains the code to teardown your specs.
|
||||
* @param timeout Custom timeout for an async afterAll
|
||||
*/
|
||||
declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterAll(action: ImplementationCallback, timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Create an expectation for a spec.
|
||||
@@ -268,11 +270,11 @@ declare namespace jasmine {
|
||||
execute(): void;
|
||||
describe(description: string, specDefinitions: () => void): Suite;
|
||||
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
|
||||
beforeEach(beforeEachFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
beforeAll(beforeAllFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
beforeEach(beforeEachFunction: ImplementationCallback, timeout?: number): void;
|
||||
beforeAll(beforeAllFunction: ImplementationCallback, timeout?: number): void;
|
||||
currentRunner(): Runner;
|
||||
afterEach(afterEachFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
afterAll(afterAllFunction: (done: DoneFn) => void, timeout?: number): void;
|
||||
afterEach(afterEachFunction: ImplementationCallback, timeout?: number): void;
|
||||
afterAll(afterAllFunction: ImplementationCallback, timeout?: number): void;
|
||||
xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
||||
it(description: string, func: () => void): Spec;
|
||||
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
|
||||
|
||||
Reference in New Issue
Block a user