forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodeunit.d.ts
66 lines (57 loc) · 2.2 KB
/
nodeunit.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Type definitions for nodeunit
// Project: https://github.com/caolan/nodeunit
// Definitions by: Jeff Goddard <https://github.com/jedigo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/nodeunit.d.ts
declare module 'nodeunit' {
export interface ITestCase {
(testCase: {[property: string]: ITestBody | ITestGroup | void}) : void;
}
export var testCase : ITestCase;
export interface Test {
done: ICallbackFunction;
expect(num: number): void;
//assersions from node assert module
fail(actual: any, expected: any, message: string, operator: string): void;
assert(value: any, message: string): void;
ok(value: any, message?: string): void;
equal(actual: any, expected: any, message?: string): void;
notEqual(actual: any, expected: any, message?: string): void;
deepEqual(actual: any, expected: any, message?: string): void;
notDeepEqual(actual: any, expected: any, message?: string): void;
strictEqual(actual: any, expected: any, message?: string): void;
notStrictEqual(actual: any, expected: any, message?: string): void;
throws(block: any, error?: any, message?: string): void;
doesNotThrow(block: any, error?: any, message?: string): void;
ifError(value: any): void;
//assertion wrappers
equals(actual: any, expected: any, message?: string): void;
same(actual: any, expected: any, message?: string): void;
}
// Test Group Usage:
// var testGroup: nodeunit.ITestGroup = {
// setUp: (callback) => {
// callback();
// },
// tearDown: (callback) => {
// callback();
// },
// test1: (test: nodeunit.Test) => {
// test.done();
// }
// }
// exports.testgroup = testGroup;
export interface ITestBody {
(callback: Test): void;
}
export interface ITestGroup {
/** The setUp function is run before each test */
setUp?: (callback: ICallbackFunction) => void;
/** The tearDown function is run after each test calls test.done() */
tearDown?: (callback: ICallbackFunction) => void;
[property: string] : ITestGroup | ITestBody | ((callback: ICallbackFunction) => void);
}
export interface ICallbackFunction {
(err?: any): void;
}
}