From 372a2c4cd967a8a38b4e92cc5192a36dddfb0ffc Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Tue, 12 May 2015 11:56:55 -0700 Subject: [PATCH 1/2] Updating the mocha type definitions --- mocha/mocha.d.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index 3f5d3e571..63ad66014 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -52,7 +52,7 @@ interface MochaDone { declare var mocha: Mocha; -declare var describe : { +declare var describe: { (description: string, spec: () => void): void; only(description: string, spec: () => void): void; skip(description: string, spec: () => void): void; @@ -60,12 +60,20 @@ declare var describe : { } // alias for `describe` -declare var context : { +declare var context: { (contextTitle: string, spec: () => void): void; only(contextTitle: string, spec: () => void): void; skip(contextTitle: string, spec: () => void): void; timeout(ms: number): void; -} +}; + +// alias for `describe` +declare var suite: { + (suiteTitle: string, spec: () => void): void; + only(suiteTitle: string, spec: () => void): void; + skip(suiteTitle: string, spec: () => void): void; + timeout(ms: number): void; +}; declare var it: { (expectation: string, assertion?: () => void): void; @@ -77,6 +85,17 @@ declare var it: { timeout(ms: number): void; }; +// alias for `it` +declare var test: { + (expectation: string, assertion?: () => void): void; + (expectation: string, assertion?: (done: MochaDone) => void): void; + only(expectation: string, assertion?: () => void): void; + only(expectation: string, assertion?: (done: MochaDone) => void): void; + skip(expectation: string, assertion?: () => void): void; + skip(expectation: string, assertion?: (done: MochaDone) => void): void; + timeout(ms: number): void; +}; + declare function before(action: () => void): void; declare function before(action: (done: MochaDone) => void): void; From 66d8808c98856feae7d5a2d5acfc955110fb126d Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Tue, 12 May 2015 11:57:21 -0700 Subject: [PATCH 2/2] Adding test for new mocha API --- mocha/mocha-tests.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index dffd86e44..f90fefaf9 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -24,6 +24,18 @@ function test_context() { }); } +function test_suite() { + suite('some context', () => { }); + + suite.only('some context', () => { }); + + suite.skip('some context', () => { }); + + suite('some context', function() { + this.timeout(2000); + }); +} + function test_it() { it('does something', () => { }); @@ -39,6 +51,21 @@ function test_it() { }); } +function test_test() { + + test('does something', () => { }); + + test('does something', (done) => { done(); }); + + test.only('does something', () => { }); + + test.skip('does something', () => { }); + + test('does something', function () { + this.timeout(2000); + }); +} + function test_before() { before(() => { }); @@ -221,4 +248,4 @@ function test_run_withOnComplete() { instance.run((failures: number): void => { console.log(failures); }); -} \ No newline at end of file +}