Name: js-handler/node_modules/nodeunit/test/test-runtest.js
| 1: | /* THIS FILE SHOULD BE BROWSER-COMPATIBLE JS! |
| 2: | * You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build. |
| 3: | * Only code on that line will be removed, its mostly to avoid requiring code |
| 4: | * that is node specific |
| 5: | */ |
| 6: | |
| 7: | var nodeunit = require('../lib/nodeunit'); // @REMOVE_LINE_FOR_BROWSER |
| 8: | |
| 9: | |
| 10: | exports.testArgs = function (test) { |
| 11: | test.ok(test.expect instanceof Function, 'test.expect'); |
| 12: | test.ok(test.done instanceof Function, 'test.done'); |
| 13: | test.ok(test.ok instanceof Function, 'test.ok'); |
| 14: | test.ok(test.same instanceof Function, 'test.same'); |
| 15: | test.ok(test.equals instanceof Function, 'test.equals'); |
| 16: | test.done(); |
| 17: | }; |
| 18: | |
| 19: | exports.testDoneCallback = function (test) { |
| 20: | test.expect(4); |
| 21: | nodeunit.runTest('testname', exports.testArgs, { |
| 22: | testDone: function (name, assertions) { |
| 23: | test.equals(assertions.failures(), 0, 'failures'); |
| 24: | test.equals(assertions.length, 5, 'length'); |
| 25: | test.ok(typeof assertions.duration === "number"); |
| 26: | test.equals(name, 'testname'); |
| 27: | } |
| 28: | }, test.done); |
| 29: | }; |
| 30: | |
| 31: | exports.testThrowError = function (test) { |
| 32: | test.expect(3); |
| 33: | var err = new Error('test'); |
| 34: | var testfn = function (test) { |
| 35: | throw err; |
| 36: | }; |
| 37: | nodeunit.runTest('testname', testfn, { |
| 38: | log: function (assertion) { |
| 39: | test.same(assertion.error, err, 'assertion.error'); |
| 40: | }, |
| 41: | testDone: function (name, assertions) { |
| 42: | test.equals(assertions.failures(), 1); |
| 43: | test.equals(assertions.length, 1); |
| 44: | } |
| 45: | }, test.done); |
| 46: | }; |
