-
Notifications
You must be signed in to change notification settings - Fork 361
Expand file tree
/
Copy pathtest-runtest.js
More file actions
51 lines (46 loc) · 1.7 KB
/
test-runtest.js
File metadata and controls
51 lines (46 loc) · 1.7 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
47
48
49
50
51
/* 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
var expectedName = 'testArgs';
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.equals(test.name, expectedName);
test.done();
};
exports.testDoneCallback = function (test) {
test.expect(4);
var oldName = expectedName;
expectedName = 'testname';
nodeunit.runTest(expectedName, exports.testArgs, {
testDone: function (name, assertions) {
expectedName = oldName;
test.equals(assertions.failures(), 0, 'failures');
test.equals(assertions.length, 6, '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);
};