2 var vows = require('vows')
3 , assert = require('assert')
4 , sandbox = require('sandboxed-module')
6 error: function(format, label, message) {
7 this.logged = [ format, label, message ];
10 , globals = function(debugValue) {
14 'NODE_DEBUG': debugValue
21 vows.describe('../lib/debug').addBatch({
22 'when NODE_DEBUG is set to log4js': {
24 var debug = sandbox.require(
26 { 'globals': globals('log4js') }
29 fakeConsole.logged = [];
30 debug('cheese')('biscuits');
31 return fakeConsole.logged;
33 'it should log to console.error': function(logged) {
34 assert.equal(logged[0], 'LOG4JS: (%s) %s');
35 assert.equal(logged[1], 'cheese');
36 assert.equal(logged[2], 'biscuits');
40 'when NODE_DEBUG is set to not log4js': {
42 var debug = sandbox.require(
44 { globals: globals('other_module') }
47 fakeConsole.logged = [];
48 debug('cheese')('biscuits');
49 return fakeConsole.logged;
51 'it should not log to console.error': function(logged) {
52 assert.equal(logged.length, 0);
56 'when NODE_DEBUG is not set': {
58 var debug = sandbox.require(
60 { globals: globals(null) }
63 fakeConsole.logged = [];
64 debug('cheese')('biscuits');
65 return fakeConsole.logged;
67 'it should not log to console.error': function(logged) {
68 assert.equal(logged.length, 0);