MCPcopy Index your code
hub / github.com/caolan/nodeunit / makeTest

Function makeTest

test/test-base.js:60–104  ·  view source on GitHub ↗
(method, args_pass, args_fail)

Source from the content-addressed store, hash-verified

58
59// generates test functions for nodeunit assertions
60var makeTest = function (method, args_pass, args_fail) {
61 return function (test) {
62 var test1_called = false;
63 var test2_called = false;
64
65 // test pass
66 nodeunit.runTest(
67 'testname',
68 function (test) {
69 test[method].apply(test, args_pass);
70 test.done();
71 },
72 {testDone: function (name, assertions) {
73 assert.equal(assertions.length, 1);
74 assert.equal(assertions.failures(), 0);
75 }},
76 function () {
77 test1_called = true;
78 }
79 );
80
81 // test failure
82 nodeunit.runTest(
83 'testname',
84 function (test) {
85 test[method].apply(test, args_fail);
86 test.done();
87 },
88 {testDone: function (name, assertions) {
89 assert.equal(assertions.length, 1);
90 assert.equal(assertions.failures(), 1);
91 }},
92 function () {
93 test2_called = true;
94 }
95 );
96
97 // ensure tests were run
98 waitFor(function () {
99 assert.ok(test1_called);
100 assert.ok(test2_called);
101 tests_called[method] = true;
102 }, 500, test.done);
103 };
104};
105
106// ensure basic assertions are working:
107exports.testOk = makeTest('ok', [true], [false]);

Callers 1

test-base.jsFile · 0.85

Calls 1

waitForFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…