Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / log4js / test / debug-test.js
1 "use strict";
2 var vows = require('vows')
3 , assert = require('assert')
4 , sandbox = require('sandboxed-module')
5 , fakeConsole = {
6   error: function(format, label, message) {
7     this.logged = [ format, label, message ];
8   }
9 }
10 , globals = function(debugValue) {
11   return {
12     process: {
13       env: {
14         'NODE_DEBUG': debugValue
15       }
16     },
17     console: fakeConsole
18   };
19 };
20
21 vows.describe('../lib/debug').addBatch({
22   'when NODE_DEBUG is set to log4js': {
23     topic: function() {
24       var debug = sandbox.require(
25         '../lib/debug', 
26         { 'globals': globals('log4js') }
27       );
28
29       fakeConsole.logged = [];
30       debug('cheese')('biscuits');
31       return fakeConsole.logged;
32     },
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');
37     }
38   },
39
40   'when NODE_DEBUG is set to not log4js': {
41     topic: function() {
42       var debug = sandbox.require(
43         '../lib/debug',
44         { globals: globals('other_module') }
45       );
46
47       fakeConsole.logged = [];
48       debug('cheese')('biscuits');
49       return fakeConsole.logged;
50     },
51     'it should not log to console.error': function(logged) {
52       assert.equal(logged.length, 0);
53     }
54   },
55
56   'when NODE_DEBUG is not set': {
57     topic: function() {
58       var debug = sandbox.require(
59         '../lib/debug',
60         { globals: globals(null) }
61       );
62
63       fakeConsole.logged = [];
64       debug('cheese')('biscuits');
65       return fakeConsole.logged;
66     },
67     'it should not log to console.error': function(logged) {
68       assert.equal(logged.length, 0);
69     }
70   }
71
72 }).exportTo(module);