Introduce done function declaration with fail method (#8891)

This commit is contained in:
mmmichl
2016-04-12 22:44:38 +09:00
committed by Masahiro Wakame
parent 883f016ef7
commit 5c182b9af7
2 changed files with 19 additions and 12 deletions
+5 -5
View File
@@ -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);
});
+14 -7
View File
@@ -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;