Add mocha members and comment existing used interface

This commit is contained in:
Jacob Boland
2013-10-15 16:49:44 -07:00
parent b24f27d014
commit 9a3601f934
2 changed files with 120 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
/// <reference path="mocha.d.ts" />
var mocha: Mocha;
function test_describe() {
describe('something', () => { });
@@ -49,4 +51,85 @@ function test_afterEach() {
afterEach(() => { });
afterEach((done) => { done(); });
}
}
function test_reporter_string(){
mocha.reporter('html');
}
function test_reporter_function(){
mocha.reporter(function(){});
}
function test_setup_slow_option(){
mocha.setup({slow: 25});
}
function test_setup_timeout_option(){
mocha.setup({timeout: 25});
}
function test_setup_globals_option(){
mocha.setup({globals: ['mocha']});
}
function test_setup_ui_option(){
mocha.setup({ui: 'bdd'});
}
function test_setup_reporter_string_option(){
mocha.setup({reporter: 'html'});
}
function test_setup_reporter_function_option(){
mocha.setup({reporter: function(){}});
}
function test_setup_bail_option(){
mocha.setup({bail: false});
}
function test_setup_ignore_leaks_option(){
mocha.setup({ignoreLeaks: false});
}
function test_setup_grep_string_option(){
mocha.setup({grep: "describe"});
}
function test_setup_grep_regex_option(){
mocha.setup({grep: new RegExp('describe')});
}
function test_setup_grep_regex_literal_option(){
mocha.setup({grep: /(expect|should)/i });
}
function test_setup_all_options(){
mocha.setup({
slow: 25,
timeout: 25,
ui: 'bdd',
globals: ['mocha'],
reporter: 'html',
bail: true,
ignoreLeaks: true,
grep: 'test'
});
}
function test_run(){
mocha.run(function(){})
}
function test_growl(){
mocha.growl();
}
function test_chaining(){
mocha
.setup({slow:25})
.growl()
.reporter('html')
.reporter(function(){});
}

40
mocha/mocha.d.ts vendored
View File

@@ -4,14 +4,46 @@
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
interface Mocha {
setup(options: MochaSetupOptions): void;
// Setup mocha with the given setting options.
setup(options: MochaSetupOptions): Mocha;
//Run tests and invoke `fn()` when complete.
run(callback: () => void): void;
// Set reporter as function
reporter(reporter: () => void): Mocha;
// Set reporter, defaults to "dot"
reporter(reporter: string): Mocha;
// Enable growl support.
growl(): Mocha
}
interface MochaSetupOptions {
slow: number;
timeout: number;
ui: string;
//milliseconds to wait before considering a test slow
slow?: number;
// timeout in milliseconds
timeout?: number;
// ui name "bdd", "tdd", "exports" etc
ui?: string;
//array of accepted globals
globals?: Array;
// reporter instance (function or string), defaults to `mocha.reporters.Dot`
reporter?: any;
// bail on the first test failure
bail?: Boolean;
// ignore global leaks
ignoreLeaks?: Boolean;
// grep string or regexp to filter tests with
grep?: any;
}
declare var describe : {