Merge pull request #14071 from destroyerofbuilds/fix/mocha/IHookCallbackContext

fix(mocha): add index definition
This commit is contained in:
Bowden Kelly 2017-02-03 18:25:15 -08:00 committed by GitHub
commit 1a428e1fdb
2 changed files with 60 additions and 0 deletions

2
mocha/index.d.ts vendored
View File

@ -120,6 +120,7 @@ declare namespace Mocha {
interface IHookCallbackContext {
skip(): void;
timeout(ms: number): void;
[index: string]: any;
}
@ -128,6 +129,7 @@ declare namespace Mocha {
timeout(ms: number): void;
retries(n: number): void;
slow(ms: number): void;
[index: string]: any;
}
/** Partial interface for Mocha's `Runnable` class. */

View File

@ -47,6 +47,8 @@ function test_it() {
it('does something', () => { });
it('does something', function () { this['sharedState'] = true; });
it('does something', (done) => { done(); });
it.only('does something', () => { });
@ -64,6 +66,8 @@ function test_test() {
test('does something', () => { });
test('does something', function () { this['sharedState'] = true; });
test('does something', (done) => { done(); });
test.only('does something', () => { });
@ -81,6 +85,8 @@ function test_specify() {
specify('does something', () => { });
specify('does something', function () { this['sharedState'] = true; });
specify('does something', (done) => { done(); });
specify.only('does something', () => { });
@ -97,6 +103,8 @@ function test_specify() {
function test_before() {
before(() => { });
before(function () { this['sharedState'] = true; });
before((done) => { done(); });
before("my description", () => { });
@ -120,6 +128,17 @@ function test_setup() {
string = this.currentTest.state;
});
setup(function() {
this['sharedState'] = true;
boolean = this.currentTest.async;
boolean = this.currentTest.pending;
boolean = this.currentTest.sync;
boolean = this.currentTest.timedOut;
string = this.currentTest.title;
string = this.currentTest.fullTitle();
string = this.currentTest.state;
});
setup(function (done) {
done();
boolean = this.currentTest.async;
@ -135,6 +154,8 @@ function test_setup() {
function test_after() {
after(() => { });
after(function () { this['sharedState'] = true; });
after((done) => { done(); });
after("my description", () => { });
@ -153,6 +174,17 @@ function test_teardown() {
string = this.currentTest.state;
});
teardown(function() {
this['sharedState'] = true;
boolean = this.currentTest.async;
boolean = this.currentTest.pending;
boolean = this.currentTest.sync;
boolean = this.currentTest.timedOut;
string = this.currentTest.title;
string = this.currentTest.fullTitle();
string = this.currentTest.state;
});
teardown(function(done) {
done();
boolean = this.currentTest.async;
@ -176,6 +208,17 @@ function test_beforeEach() {
string = this.currentTest.state;
});
beforeEach(function () {
this['sharedState'] = true;
boolean = this.currentTest.async;
boolean = this.currentTest.pending;
boolean = this.currentTest.sync;
boolean = this.currentTest.timedOut;
string = this.currentTest.title;
string = this.currentTest.fullTitle();
string = this.currentTest.state;
});
beforeEach(function (done) {
done();
boolean = this.currentTest.async;
@ -212,6 +255,8 @@ function test_beforeEach() {
function test_suiteSetup() {
suiteSetup(() => { });
suiteSetup(function () { this['sharedState'] = true; });
suiteSetup((done) => { done(); });
}
@ -226,6 +271,17 @@ function test_afterEach() {
string = this.currentTest.state;
});
afterEach(function () {
this['sharedState'] = true;
boolean = this.currentTest.async;
boolean = this.currentTest.pending;
boolean = this.currentTest.sync;
boolean = this.currentTest.timedOut;
string = this.currentTest.title;
string = this.currentTest.fullTitle();
string = this.currentTest.state;
});
afterEach(function (done) {
done();
boolean = this.currentTest.async;
@ -263,6 +319,8 @@ function test_afterEach() {
function test_suiteTeardown() {
suiteTeardown(() => { });
suiteTeardown(function () { this['sharedState'] = true; });
suiteTeardown((done) => { done(); });
}