05e65f93caccb3f1988b9e3eefa05c4d1ff485d3.svn-base
1.53 KB
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
/* THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
* You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build.
* Only code on that line will be removed, its mostly to avoid requiring code
* that is node specific
*/
var nodeunit = require('../lib/nodeunit'); // @REMOVE_LINE_FOR_BROWSER
exports.testArgs = function (test) {
test.ok(test.expect instanceof Function, 'test.expect');
test.ok(test.done instanceof Function, 'test.done');
test.ok(test.ok instanceof Function, 'test.ok');
test.ok(test.same instanceof Function, 'test.same');
test.ok(test.equals instanceof Function, 'test.equals');
test.done();
};
exports.testDoneCallback = function (test) {
test.expect(4);
nodeunit.runTest('testname', exports.testArgs, {
testDone: function (name, assertions) {
test.equals(assertions.failures(), 0, 'failures');
test.equals(assertions.length, 5, 'length');
test.ok(typeof assertions.duration === "number");
test.equals(name, 'testname');
}
}, test.done);
};
exports.testThrowError = function (test) {
test.expect(3);
var err = new Error('test');
var testfn = function (test) {
throw err;
};
nodeunit.runTest('testname', testfn, {
log: function (assertion) {
test.same(assertion.error, err, 'assertion.error');
},
testDone: function (name, assertions) {
test.equals(assertions.failures(), 1);
test.equals(assertions.length, 1);
}
}, test.done);
};