File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ module.exports = function logger() {
6161 // Retunrns the logger
6262 function log ( msg , ctx ) {
6363 msg = msg || '' ;
64- if ( ! ctx ) {
64+ if ( ctx == null ) {
6565 ctx = { } ;
6666 }
6767
Original file line number Diff line number Diff line change @@ -37,12 +37,24 @@ describe('TerminalAdapter', function () {
3737 } ) ;
3838
3939 describe ( '#log()' , function ( ) {
40+ var logMessage ;
41+ var stderrWriteBackup = process . stderr . write ;
42+
4043 beforeEach ( function ( ) {
4144 this . spyerror = sinon . spy ( console , 'error' ) ;
45+
46+ logMessage = '' ;
47+ process . stderr . write = ( function ( write ) {
48+ return function ( str , encoding , fd ) {
49+ logMessage = str ;
50+ } ;
51+ } ( process . stderr . write ) ) ;
4252 } ) ;
4353
4454 afterEach ( function ( ) {
4555 console . error . restore ( ) ;
56+
57+ process . stderr . write = stderrWriteBackup ;
4658 } ) ;
4759
4860 it ( 'calls console.error and perform strings interpolation' , function ( ) {
@@ -52,7 +64,16 @@ describe('TerminalAdapter', function () {
5264 reps : 'reps'
5365 } ) ;
5466 assert ( this . spyerror . withArgs ( 'has many reps' ) . calledOnce ) ;
67+ assert . equal ( logMessage , 'has many reps\n' ) ;
5568 } ) ;
69+
70+ it ( 'substitutes strings correctly when context argument is falsey' , function ( ) {
71+ this . adapter . log ( 'Zero = %d, One = %s' , 0 , 1 ) ;
72+
73+ assert ( this . spyerror . calledOnce ) ;
74+ assert . equal ( logMessage , 'Zero = 0, One = 1\n' ) ;
75+ } ) ;
76+
5677 } ) ;
5778
5879 describe ( '#log' , function ( ) {
You can’t perform that action at this time.
0 commit comments