File tree Expand file tree Collapse file tree 2 files changed +97
-12
lines changed Expand file tree Collapse file tree 2 files changed +97
-12
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ var block: () =>{
14
14
} ;
15
15
16
16
export var testGroup : nodeunit . ITestGroup = {
17
- setUp : function ( callback : nodeunit . ICallbackFunction ) {
17
+ setUp : ( callback ) => {
18
18
callback ( ) ;
19
19
} ,
20
- tearDown : function ( callback : nodeunit . ICallbackFunction ) {
20
+ tearDown : ( callback ) => {
21
21
callback ( ) ;
22
22
} ,
23
23
test1 : function ( test : nodeunit . Test ) {
@@ -55,5 +55,83 @@ export var testGroup: nodeunit.ITestGroup = {
55
55
56
56
test . done ( error ) ;
57
57
test . done ( ) ;
58
+ } ,
59
+ "This is a test with a nice description" : ( test : nodeunit . Test ) => {
60
+ test . done ( ) ;
58
61
}
59
62
} ;
63
+
64
+
65
+ // see https://github.com/caolan/nodeunit/blob/master/examples/nested/nested_reporter_test.unit.js for example.
66
+ // (https://github.com/caolan/nodeunit/commit/9fee91149324f79753eadbcf8993399a7d76da40)
67
+
68
+
69
+
70
+ var testCase = nodeunit . testCase ;
71
+
72
+ export var testCaseGroup = testCase ( {
73
+ "Test 0.1" : function ( test : nodeunit . Test ) {
74
+ test . ok ( true ) ;
75
+ test . done ( ) ;
76
+ } ,
77
+
78
+ "TC 1" : testCase ( {
79
+ "TC 1.1" : testCase ( {
80
+ "Test 1.1.1" : function ( test : nodeunit . Test ) {
81
+ test . ok ( true ) ;
82
+ test . done ( ) ;
83
+ }
84
+ } )
85
+ } ) ,
86
+
87
+ "TC 2" : testCase ( {
88
+ "TC 2.1" : testCase ( {
89
+ "TC 2.1.1" : testCase ( {
90
+ "Test 2.1.1.1" : function ( test : nodeunit . Test ) {
91
+ test . ok ( true ) ;
92
+ test . done ( ) ;
93
+ } ,
94
+
95
+ "Test 2.1.1.2" : function ( test : nodeunit . Test ) {
96
+ test . ok ( true ) ;
97
+ test . done ( ) ;
98
+ }
99
+ } ) ,
100
+
101
+ "TC 2.2.1" : testCase ( {
102
+ "Test 2.2.1.1" : function ( test : nodeunit . Test ) {
103
+ test . ok ( true ) ;
104
+ test . done ( ) ;
105
+ } ,
106
+
107
+ "TC 2.2.1.1" : testCase ( {
108
+ "Test 2.2.1.1.1" : function ( test : nodeunit . Test ) {
109
+ test . ok ( true ) ;
110
+ test . done ( ) ;
111
+ } ,
112
+ } ) ,
113
+
114
+ "Test 2.2.1.2" : function ( test : nodeunit . Test ) {
115
+ test . ok ( true ) ;
116
+ test . done ( ) ;
117
+ }
118
+ } )
119
+ } )
120
+ } ) ,
121
+
122
+ "TC 3" : testCase ( {
123
+ "TC 3.1" : testCase ( {
124
+ "TC 3.1.1" : testCase ( {
125
+ "Test 3.1.1.1 (should fail)" : function ( test : nodeunit . Test ) {
126
+ test . ok ( false ) ;
127
+ test . done ( ) ;
128
+ }
129
+ } )
130
+ } )
131
+ } )
132
+ } ) ;
133
+
134
+
135
+
136
+
137
+
Original file line number Diff line number Diff line change 6
6
// Imported from: https://github.com/soywiz/typescript-node-definitions/nodeunit.d.ts
7
7
8
8
declare module 'nodeunit' {
9
+ export interface ITestCase {
10
+ ( testCase : { [ property : string ] : ITestBody | ITestGroup | void } ) : void ;
11
+ }
12
+ export var testCase : ITestCase ;
13
+
9
14
export interface Test {
10
15
done : ICallbackFunction ;
11
16
expect ( num : number ) : void ;
@@ -31,15 +36,15 @@ declare module 'nodeunit' {
31
36
32
37
// Test Group Usage:
33
38
// var testGroup: nodeunit.ITestGroup = {
34
- // setUp: function (callback: nodeunit.ICallbackFunction): void {
35
- // callback();
36
- // },
37
- // tearDown: function (callback: nodeunit.ICallbackFunction): void {
38
- // callback();
39
- // },
40
- // test1: function (test: nodeunit.Test): void {
41
- // test.done();
42
- // }
39
+ // setUp: (callback) => {
40
+ // callback();
41
+ // },
42
+ // tearDown: (callback) => {
43
+ // callback();
44
+ // },
45
+ // test1: (test: nodeunit.Test) => {
46
+ // test.done();
47
+ // }
43
48
// }
44
49
// exports.testgroup = testGroup;
45
50
@@ -48,12 +53,14 @@ declare module 'nodeunit' {
48
53
}
49
54
50
55
export interface ITestGroup {
56
+ /** The setUp function is run before each test */
51
57
setUp ?: ( callback : ICallbackFunction ) => void ;
58
+ /** The tearDown function is run after each test calls test.done() */
52
59
tearDown ?: ( callback : ICallbackFunction ) => void ;
60
+ [ property : string ] : ITestGroup | ITestBody | ( ( callback : ICallbackFunction ) => void ) ;
53
61
}
54
62
55
63
export interface ICallbackFunction {
56
64
( err ?: any ) : void ;
57
65
}
58
66
}
59
-
You can’t perform that action at this time.
0 commit comments