@@ -48,8 +48,8 @@ describe('Log Commands', () => {
4848 expect (
4949 setStub . calledWith ( 'log' , {
5050 level : 'debug' ,
51- path : './logs/app.log' ,
52- showConsoleLogs : false ,
51+ path : expectedAbsolutePath , // Should be directory path, not file path
52+ 'show-console-logs' : false ,
5353 } ) ,
5454 ) . to . be . true ;
5555
@@ -88,13 +88,9 @@ describe('Log Commands', () => {
8888
8989 await cmd . run ( ) ;
9090
91- expect (
92- setStub . calledWith ( 'log' , {
93- level : 'info' ,
94- path : './custom/logs/app.log' ,
95- showConsoleLogs : false ,
96- } ) ,
97- ) . to . be . true ;
91+ // Should call set even when no flags are provided
92+ expect ( setStub . called ) . to . be . true ;
93+ expect ( setStub . calledWith ( 'log' , { } ) ) . to . be . true ;
9894
9995 // Should not display any success messages when no flags are provided
10096 expect ( successMessage . length ) . to . equal ( 0 ) ;
@@ -121,8 +117,8 @@ describe('Log Commands', () => {
121117 expect (
122118 setStub . calledWith ( 'log' , {
123119 level : 'warn' ,
124- path : './existing/logs/app.log' ,
125- showConsoleLogs : false ,
120+ path : existingPath , // Should preserve existing path unchanged
121+ 'show-console-logs' : true , // Should preserve existing console logs setting
126122 } ) ,
127123 ) . to . be . true ;
128124
@@ -153,8 +149,8 @@ describe('Log Commands', () => {
153149 expect (
154150 setStub . calledWith ( 'log' , {
155151 level : 'error' ,
156- path : './new/logs/app.log' ,
157- showConsoleLogs : false ,
152+ path : expectedAbsolutePath ,
153+ 'show-console-logs' : false ,
158154 } ) ,
159155 ) . to . be . true ;
160156
@@ -176,9 +172,9 @@ describe('Log Commands', () => {
176172
177173 expect (
178174 setStub . calledWith ( 'log' , {
179- level : 'info' ,
180- path : './logs/app .log' ,
181- showConsoleLogs : true ,
175+ level : 'debug' ,
176+ path : './existing .log' ,
177+ 'show-console-logs' : true ,
182178 } ) ,
183179 ) . to . be . true ;
184180
@@ -201,8 +197,7 @@ describe('Log Commands', () => {
201197 expect (
202198 setStub . calledWith ( 'log' , {
203199 level : 'info' ,
204- path : './logs/app.log' ,
205- showConsoleLogs : false ,
200+ 'show-console-logs' : false ,
206201 } ) ,
207202 ) . to . be . true ;
208203
@@ -232,8 +227,8 @@ describe('Log Commands', () => {
232227 expect (
233228 setStub . calledWith ( 'log' , {
234229 level : 'warn' ,
235- path : './logs/warnings.log' ,
236- showConsoleLogs : true ,
230+ path : expectedAbsolutePath ,
231+ 'show-console-logs' : true ,
237232 } ) ,
238233 ) . to . be . true ;
239234
@@ -262,9 +257,8 @@ describe('Log Commands', () => {
262257
263258 expect (
264259 setStub . calledWith ( 'log' , {
265- level : 'info' ,
266- path : './logs/app.log' ,
267- showConsoleLogs : false ,
260+ path : expectedDirectoryPath ,
261+ 'show-console-logs' : false ,
268262 } ) ,
269263 ) . to . be . true ;
270264 } ) ;
@@ -311,12 +305,22 @@ describe('Log Commands', () => {
311305 await cmd . run ( ) ;
312306
313307 expect ( tableMessage ) . to . have . length ( 1 ) ;
314- expect ( tableMessage [ 0 ] . headers ) . to . deep . equal ( [ { value : 'Log Level' } , { value : 'Log Path' } , { value : 'Show Console Logs' } ] ) ;
308+ expect ( tableMessage [ 0 ] . headers ) . to . deep . equal ( [
309+ { value : 'Setting' } ,
310+ { value : 'Value' }
311+ ] ) ;
315312 expect ( tableMessage [ 0 ] . data ) . to . deep . equal ( [
316313 {
317- 'Log Level' : 'debug' ,
318- 'Log Path' : './logs/app.log' ,
319- 'Show Console Logs' : 'Not set' ,
314+ 'Setting' : 'Log Level' ,
315+ 'Value' : 'debug'
316+ } ,
317+ {
318+ 'Setting' : 'Log Path' ,
319+ 'Value' : expectedAbsolutePath
320+ } ,
321+ {
322+ 'Setting' : 'Show Console Logs' ,
323+ 'Value' : 'false'
320324 } ,
321325 ] ) ;
322326 } ) ;
@@ -328,12 +332,22 @@ describe('Log Commands', () => {
328332 await cmd . run ( ) ;
329333
330334 expect ( tableMessage ) . to . have . length ( 1 ) ;
331- expect ( tableMessage [ 0 ] . headers ) . to . deep . equal ( [ { value : 'Log Level' } , { value : 'Log Path' } , { value : 'Show Console Logs' } ] ) ;
335+ expect ( tableMessage [ 0 ] . headers ) . to . deep . equal ( [
336+ { value : 'Setting' } ,
337+ { value : 'Value' }
338+ ] ) ;
332339 expect ( tableMessage [ 0 ] . data ) . to . deep . equal ( [
333340 {
334- 'Log Level' : 'info' ,
335- 'Log Path' : 'Not set' ,
336- 'Show Console Logs' : 'Not set' ,
341+ 'Setting' : 'Log Level' ,
342+ 'Value' : 'info'
343+ } ,
344+ {
345+ 'Setting' : 'Log Path' ,
346+ 'Value' : LOG_CONFIG_DEFAULTS . PATH
347+ } ,
348+ {
349+ 'Setting' : 'Show Console Logs' ,
350+ 'Value' : 'false'
337351 } ,
338352 ] ) ;
339353 } ) ;
@@ -348,12 +362,22 @@ describe('Log Commands', () => {
348362 await cmd . run ( ) ;
349363
350364 expect ( tableMessage ) . to . have . length ( 1 ) ;
351- expect ( tableMessage [ 0 ] . headers ) . to . deep . equal ( [ { value : 'Log Level' } , { value : 'Log Path' } , { value : 'Show Console Logs' } ] ) ;
365+ expect ( tableMessage [ 0 ] . headers ) . to . deep . equal ( [
366+ { value : 'Setting' } ,
367+ { value : 'Value' }
368+ ] ) ;
352369 expect ( tableMessage [ 0 ] . data ) . to . deep . equal ( [
353370 {
354- 'Log Level' : 'Not set' ,
355- 'Log Path' : './custom/logs/app.log' ,
356- 'Show Console Logs' : 'Not set' ,
371+ 'Setting' : 'Log Level' ,
372+ 'Value' : LOG_CONFIG_DEFAULTS . LEVEL
373+ } ,
374+ {
375+ 'Setting' : 'Log Path' ,
376+ 'Value' : expectedAbsolutePath
377+ } ,
378+ {
379+ 'Setting' : 'Show Console Logs' ,
380+ 'Value' : 'false'
357381 } ,
358382 ] ) ;
359383 } ) ;
@@ -607,4 +631,4 @@ describe('Log Commands', () => {
607631 expect ( successMessage . some ( msg => msg . includes ( 'CLI_CONFIG_LOG_PATH_SET' ) ) ) . to . be . true ;
608632 } ) ;
609633 } ) ;
610- } ) ;
634+ } ) ;
0 commit comments