[Pkg-javascript-commits] [node-tap] 83/186: fix debug function, add test for it
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 1 16:40:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-tap.
commit 8b39bcdee6ec03d63e1a7ff12cb7bc7336195f67
Author: isaacs <i at izs.me>
Date: Fri Nov 10 16:30:50 2017 -0800
fix debug function, add test for it
---
lib/base.js | 4 +---
unit/base.js | 11 ++++++++++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/base.js b/lib/base.js
index 93d9511..8c32cb7 100644
--- a/lib/base.js
+++ b/lib/base.js
@@ -235,12 +235,10 @@ class Base extends MiniPass {
}
-/* istanbul ignore next */
function debug () {
const prefix = 'TAP ' + process.pid + ' ' + this.name + ': '
const msg = util.format.apply(util, arguments).trim()
- msg = prefix + msg.split('\n').join('\n' + prefix)
- console.error(msg)
+ console.error(prefix + msg.split('\n').join('\n' + prefix))
}
module.exports = Base
diff --git a/unit/base.js b/unit/base.js
index f4f3310..22ff69d 100644
--- a/unit/base.js
+++ b/unit/base.js
@@ -12,9 +12,18 @@ t.test('basic base', t => {
})
t.test('skip + debug', t => {
- const b = new Base({ skip: true, debug: true })
+ const b = new Base({ skip: true, debug: true, name: 'name' })
+
+ const error = console.error
+ t.teardown(() => console.error = error)
+ let output
+ console.error = msg => output = msg
+
t.equal(b.main, Base.prototype.main)
t.notEqual(b.debug, Base.prototype.debug)
+ b.debug('hello', { world: '420' })
+ console.error = error
+ t.match(output.trim(), /^TAP [0-9]+ name: hello \{ world: '420' \}$/)
t.test('call main', t => b.main(t.end))
t.end()
})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap.git
More information about the Pkg-javascript-commits
mailing list