From 03529a991c4624cc4299f6ffd62da9d1fda77a71 Mon Sep 17 00:00:00 2001 From: Howard Tang Date: Sun, 16 Mar 2014 00:03:32 -0300 Subject: [PATCH] [Breaking] tests with no callback are failed TODO tests --- example/no_callback.js | 3 +++ lib/test.js | 3 +++ test/no_callback.js | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 example/no_callback.js diff --git a/example/no_callback.js b/example/no_callback.js new file mode 100644 index 00000000..e1a11e83 --- /dev/null +++ b/example/no_callback.js @@ -0,0 +1,3 @@ +var test = require('../'); + +test('No cb test'); diff --git a/lib/test.js b/lib/test.js index 97247b34..d2e0c85d 100644 --- a/lib/test.js +++ b/lib/test.js @@ -178,6 +178,9 @@ Test.prototype.end = function (err) { Test.prototype._end = function (err) { var self = this; + + if (!this._cb && !this._todo) this.fail('# TODO ' + this.name); + if (this._progeny.length) { var t = this._progeny.shift(); t.on('end', function () { self._end(); }); diff --git a/test/no_callback.js b/test/no_callback.js index 760ff26c..750275ac 100644 --- a/test/no_callback.js +++ b/test/no_callback.js @@ -1,3 +1,35 @@ -var test = require('../'); +var tape = require('../'); +var tap = require('tap'); +var concat = require('concat-stream'); -test('No callback.'); +var stripFullStack = require('./common').stripFullStack; + +tap.test('no callback', function (tt) { + tt.plan(1); + + var test = tape.createHarness(); + var tc = function (rows) { + var body = stripFullStack(rows.toString('utf8')); + + tt.same(body, [ + 'TAP version 13', + '# No callback.', + 'not ok 1 # TODO No callback.', + ' ---', + ' operator: fail', + ' stack: |-', + ' Error: # TODO No callback.', + ' [... stack stripped ...]', + ' ...', + '', + '1..1', + '# tests 1', + '# pass 0', + '# fail 1', + ].join('\n') + '\n'); + }; + + test.createStream().pipe(concat(tc)); + + test('No callback.'); +});