@@ -6,60 +6,62 @@ import {
66 LOG_EXTERNAL_COLOR ,
77 LOG_ERROR_COLOR ,
88} from '@constants/index' ;
9- import ConsoleLogDriver from '@drivers/console-log' ;
10- import { LogType } from '@interfaces/drivers/log-driver ' ;
9+ import ConsoleLog from '@drivers/console-log' ;
10+ import { LogType } from '@interfaces/drivers/console-log ' ;
1111
1212describe ( 'drivers/console-log' , ( ) => {
13+ let consoleInfoStub = sinon . stub ( ) ;
14+
1315 const message = 'hello world' ;
1416 const getMessage = ( ) => message ;
1517
1618 beforeEach ( ( ) => {
17- sinon . stub ( console , 'info' ) ;
19+ consoleInfoStub = sinon . stub ( console , 'info' ) ;
1820 } ) ;
1921
2022 afterEach ( ( ) => {
2123 sinon . restore ( ) ;
2224 } ) ;
2325
2426 it ( 'should correct log default type output' , ( ) => {
25- ConsoleLogDriver ( getMessage ) ;
27+ ConsoleLog ( ) ( getMessage ) ;
2628
27- expect ( console . info ) . calledOnceWith ( LOG_INFO_COLOR , sinon . match ( message ) ) ;
29+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_INFO_COLOR , sinon . match ( message ) ) ;
2830 } ) ;
2931
3032 it ( 'should correct log IN INTERNAL output' , ( ) => {
31- ConsoleLogDriver ( getMessage , LogType . REQ_INTERNAL , 1 ) ;
33+ ConsoleLog ( ) ( getMessage , LogType . REQ_INTERNAL , 1 ) ;
3234
33- expect ( console . info ) . calledOnceWith ( LOG_INTERNAL_COLOR , sinon . match ( message ) ) ;
35+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_INTERNAL_COLOR , sinon . match ( message ) ) ;
3436 } ) ;
3537
3638 it ( 'should correct log OUT INTERNAL output' , ( ) => {
37- ConsoleLogDriver ( getMessage , LogType . RES_INTERNAL , 1 ) ;
39+ ConsoleLog ( ) ( getMessage , LogType . RES_INTERNAL , 1 ) ;
3840
39- expect ( console . info ) . calledOnceWith ( LOG_INTERNAL_COLOR , sinon . match ( message ) ) ;
41+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_INTERNAL_COLOR , sinon . match ( message ) ) ;
4042 } ) ;
4143
4244 it ( 'should correct log IN EXTERNAL output' , ( ) => {
43- ConsoleLogDriver ( getMessage , LogType . REQ_EXTERNAL , 1 ) ;
45+ ConsoleLog ( ) ( getMessage , LogType . REQ_EXTERNAL , 1 ) ;
4446
45- expect ( console . info ) . calledOnceWith ( LOG_EXTERNAL_COLOR , sinon . match ( message ) ) ;
47+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_EXTERNAL_COLOR , sinon . match ( message ) ) ;
4648 } ) ;
4749
4850 it ( 'should correct log OUT EXTERNAL output' , ( ) => {
49- ConsoleLogDriver ( getMessage , LogType . RES_EXTERNAL , 1 ) ;
51+ ConsoleLog ( ) ( getMessage , LogType . RES_EXTERNAL , 1 ) ;
5052
51- expect ( console . info ) . calledOnceWith ( LOG_EXTERNAL_COLOR , sinon . match ( message ) ) ;
53+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_EXTERNAL_COLOR , sinon . match ( message ) ) ;
5254 } ) ;
5355
5456 it ( 'should correct log INFO output' , ( ) => {
55- ConsoleLogDriver ( getMessage , LogType . INFO , 1 ) ;
57+ ConsoleLog ( ) ( getMessage , LogType . INFO , 1 ) ;
5658
57- expect ( console . info ) . calledOnceWith ( LOG_INFO_COLOR , sinon . match ( message ) ) ;
59+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_INFO_COLOR , sinon . match ( message ) ) ;
5860 } ) ;
5961
6062 it ( 'should correct log ERROR output' , ( ) => {
61- ConsoleLogDriver ( getMessage , LogType . ERROR , 1 ) ;
63+ ConsoleLog ( ) ( getMessage , LogType . ERROR , 1 ) ;
6264
63- expect ( console . info ) . calledOnceWith ( LOG_ERROR_COLOR , sinon . match ( message ) ) ;
65+ expect ( consoleInfoStub ) . calledOnceWith ( LOG_ERROR_COLOR , sinon . match ( message ) ) ;
6466 } ) ;
6567} ) ;
0 commit comments