mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Introduce done function declaration with fail method (#8891)
This commit is contained in:
@@ -747,31 +747,31 @@ describe("Manually ticking the Jasmine Clock", function () {
|
||||
|
||||
describe("Asynchronous specs", function () {
|
||||
var value: number;
|
||||
beforeEach(function (done) {
|
||||
beforeEach(function (done: DoneFn) {
|
||||
setTimeout(function () {
|
||||
value = 0;
|
||||
done();
|
||||
}, 1);
|
||||
});
|
||||
|
||||
it("should support async execution of test preparation and expectations", function (done) {
|
||||
it("should support async execution of test preparation and expectations", function (done: DoneFn) {
|
||||
value++;
|
||||
expect(value).toBeGreaterThan(0);
|
||||
done();
|
||||
});
|
||||
|
||||
describe("long asynchronous specs", function() {
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function(done: DoneFn) {
|
||||
done();
|
||||
}, 1000);
|
||||
|
||||
it("takes a long time", function(done) {
|
||||
it("takes a long time", function(done: DoneFn) {
|
||||
setTimeout(function() {
|
||||
done();
|
||||
}, 9000);
|
||||
}, 10000);
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function(done: DoneFn) {
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
Vendored
+14
-7
@@ -11,29 +11,36 @@ declare function fdescribe(description: string, specDefinitions: () => void): vo
|
||||
declare function xdescribe(description: string, specDefinitions: () => void): void;
|
||||
|
||||
declare function it(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
|
||||
declare function pending(reason?: string): void;
|
||||
|
||||
declare function beforeEach(action: () => void, timeout?: number): void;
|
||||
declare function beforeEach(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterEach(action: () => void, timeout?: number): void;
|
||||
declare function afterEach(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
declare function beforeAll(action: () => void, timeout?: number): void;
|
||||
declare function beforeAll(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterAll(action: () => void, timeout?: number): void;
|
||||
declare function afterAll(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
declare function expect(spy: Function): jasmine.Matchers;
|
||||
declare function expect(actual: any): jasmine.Matchers;
|
||||
|
||||
declare function fail(e?: any): void;
|
||||
/** Action method that should be called when the async work is complete */
|
||||
interface DoneFn extends Function {
|
||||
(): void;
|
||||
|
||||
/** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
|
||||
fail: (message?: Error|string) => void;
|
||||
}
|
||||
|
||||
declare function spyOn(object: any, method: string): jasmine.Spy;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user