Name: js-handler/node_modules/nodeunit/node_modules/tap/test/meta-test.js
| 1: | var tap = require("../") |
| 2: | , test = tap.test |
| 3: | |
| 4: | test("meta test", { skip: false }, function (t) { |
| 5: | |
| 6: | function thr0w() { throw new Error('raburt') } |
| 7: | function noop () {} |
| 8: | |
| 9: | // this also tests the ok/notOk functions |
| 10: | t.once("end", section2) |
| 11: | t.ok(true, "true is ok") |
| 12: | t.ok(noop, "function is ok") |
| 13: | t.ok({}, "object is ok") |
| 14: | t.ok(t, "t is ok") |
| 15: | t.ok(100, "number is ok") |
| 16: | t.ok("asdf", "string is ok") |
| 17: | t.notOk(false, "false is notOk") |
| 18: | t.notOk(0, "0 is notOk") |
| 19: | t.notOk(null, "null is notOk") |
| 20: | t.notOk(undefined, "undefined is notOk") |
| 21: | t.notOk(NaN, "NaN is notOk") |
| 22: | t.notOk("", "empty string is notOk") |
| 23: | t.throws(thr0w, "Thrower throws"); |
| 24: | t.doesNotThrow(noop, "noop does not throw"); |
| 25: | t.similar({foo:"bar", bar:"foo"}, {foo:"bar"}, "similar objects are ok"); |
| 26: | t.dissimilar({}, {mandatory:"value"}, "dissimilar objects are ok"); |
| 27: | t.dissimilar(null, {}, "null is dissimilar from an object, even with no keys"); |
| 28: | |
| 29: | // a few failures. |
| 30: | t.ifError(new Error("this is an error")) |
| 31: | t.ifError({ message: "this is a custom error" }) |
| 32: | t.ok(false, "false is not ok") |
| 33: | t.notOk(true, "true is not not ok") |
| 34: | t.similar(null, {}, "Null is not similar to an object, even with no keys"); |
| 35: | t.throws(noop, "noop does not throw"); |
| 36: | t.throws(noop, new Error("Whoops!"), "noop does not throw an Error"); |
| 37: | t.throws(noop, {name:"MyError", message:"Whoops!"}, "noop does not throw a MyError"); |
| 38: | t.doesNotThrow(thr0w, "thrower does throw"); |
| 39: | |
| 40: | // things that are like other things |
| 41: | t.like("asdf", "asdf") |
| 42: | t.like("asdf", /^a.*f$/) |
| 43: | t.like(100, 100) |
| 44: | t.like(100, '100') |
| 45: | t.like(100, 100.0) |
| 46: | t.unlike("asdf", "fdsa") |
| 47: | t.unlike("asdf", /^you jelly, bro?/) |
| 48: | t.unlike(100, 100.1) |
| 49: | t.like(true, 1) |
| 50: | t.like(null, undefined) |
| 51: | t.like(true, [1]) |
| 52: | t.like(false, []) |
| 53: | t.like('', []) |
| 54: | t.end() |
| 55: | |
| 56: | function section2 () { |
| 57: | var results = t.results |
| 58: | t.clear() |
| 59: | t.ok(true, "sanity check") |
| 60: | t.notOk(results.ok, "not ok") |
| 61: | t.equal(results.tests, 39, "total test count") |
| 62: | t.equal(results.passTotal, 30, "tests passed") |
| 63: | t.equal(results.fail, 9, "tests failed") |
| 64: | t.type(results.ok, "boolean", "ok is boolean") |
| 65: | t.type(results.skip, "number", "skip is number") |
| 66: | t.type(results, "Results", "results isa Results") |
| 67: | t.type(t, "Test", "test isa Test") |
| 68: | t.type(t, "Harness", "test isa Harness") |
| 69: | t.end() |
| 70: | } |
| 71: | }) |
