Fleshed out some other ways to write tests with Nodeunit.

This commit is contained in:
Steve Ognibene
2015-08-12 16:27:16 -04:00
parent da995655d8
commit d202e275b2
2 changed files with 97 additions and 12 deletions

View File

@@ -14,10 +14,10 @@ var block: () =>{
};
export var testGroup: nodeunit.ITestGroup = {
setUp: function (callback: nodeunit.ICallbackFunction) {
setUp: (callback) => {
callback();
},
tearDown: function (callback: nodeunit.ICallbackFunction) {
tearDown: (callback) => {
callback();
},
test1: function (test: nodeunit.Test) {
@@ -55,5 +55,83 @@ export var testGroup: nodeunit.ITestGroup = {
test.done(error);
test.done();
},
"This is a test with a nice description": (test: nodeunit.Test) => {
test.done();
}
};
// see https://github.com/caolan/nodeunit/blob/master/examples/nested/nested_reporter_test.unit.js for example.
// (https://github.com/caolan/nodeunit/commit/9fee91149324f79753eadbcf8993399a7d76da40)
var testCase = nodeunit.testCase;
export var testCaseGroup = testCase({
"Test 0.1": function(test: nodeunit.Test) {
test.ok(true);
test.done();
},
"TC 1": testCase({
"TC 1.1": testCase({
"Test 1.1.1": function(test: nodeunit.Test) {
test.ok(true);
test.done();
}
})
}),
"TC 2": testCase({
"TC 2.1": testCase({
"TC 2.1.1": testCase({
"Test 2.1.1.1": function(test: nodeunit.Test) {
test.ok(true);
test.done();
},
"Test 2.1.1.2": function(test: nodeunit.Test) {
test.ok(true);
test.done();
}
}),
"TC 2.2.1": testCase({
"Test 2.2.1.1": function(test: nodeunit.Test) {
test.ok(true);
test.done();
},
"TC 2.2.1.1": testCase({
"Test 2.2.1.1.1": function(test: nodeunit.Test) {
test.ok(true);
test.done();
},
}),
"Test 2.2.1.2": function(test: nodeunit.Test) {
test.ok(true);
test.done();
}
})
})
}),
"TC 3": testCase({
"TC 3.1": testCase({
"TC 3.1.1": testCase({
"Test 3.1.1.1 (should fail)": function(test: nodeunit.Test) {
test.ok(false);
test.done();
}
})
})
})
});